package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.corona.Game;
import com.corona.game.util.SmolSprite;
import com.corona.game.util.SmolSpriteProxy;
import com.corona.game.util.TextField;
import com.corona.game.util.TextureCache;
import com.corona.game.util.texture.DynamicTextures;
import com.sun.jna.platform.win32.WinError;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

/* loaded from: pokewilds.jar:com/pkmngen/game/Tile.class */
public class Tile {
    boolean isSolid;
    boolean isLedge;
    boolean isWater;
    boolean isGrass;
    boolean isTree;
    boolean isSmashable;
    boolean isCuttable;
    boolean isHeadbuttable;
    String ledgeDir;
    public Vector2 position;
    public SmolSprite sprite;
    public SmolSprite overSprite;
    public String hasItem;
    public int hasItemAmount;
    Route routeBelongsTo;
    public boolean isTorch;
    public boolean belowBridge;
    public boolean drawAsTree;
    public boolean drawUpperBelowPlayer;
    public boolean drawSavannaTree;
    public boolean isChimney;
    public String squishedTiles;
    public String name;
    public String nameUpper;
    String biome;
    ArrayList<Vector2> doorTiles;
    HashMap<String, Integer> items;
    public boolean isBottomMtnLayer;
    String shoreOcean;
    String shoreTidal;
    boolean isTidal;
    public boolean isWaterfall;
    public boolean isLava;
    public int yOffset;

    public void squish(String tileName) {
        if (this.squishedTiles == null) {
            this.squishedTiles = "";
        }
        this.squishedTiles = tileName + "&" + this.squishedTiles;
    }

    public String unSquish() {
        if (this.squishedTiles == null) {
            return null;
        }
        String[] results = this.squishedTiles.split("\\&", 2);
        if (results.length < 2) {
            this.squishedTiles = null;
        } else {
            this.squishedTiles = results[1];
            System.out.println(this.squishedTiles);
        }
        return results[0];
    }

    public HashMap<String, Integer> items() {
        if (this.items == null) {
            this.items = new HashMap<>();
            if (this.name.equals("grass2")) {
                this.items.put("grass", 1);
                if (Game.rand.nextInt(256) < 64) {
                    this.items.put("miracle seed", 1);
                }
            } else if (this.name.equals("grass3")) {
                this.items.put("grass", 1);
            } else if (this.name.equals("grass4")) {
                this.items.put("grass", 2);
            } else if (this.name.equals("grass_sand1")) {
                this.items.put("grass", 1);
            } else if (this.name.equals("grass_sand3")) {
                this.items.put("grass", 2);
            } else if (this.name.equals("grass_graveyard1")) {
                this.items.put("grass", 2);
            } else if (this.name.equals("tree5")) {
                this.items.put("log", 2);
            } else if (this.name.contains("tree_large1")) {
                this.items.put("log", 4);
            } else if (this.nameUpper.equals("rock_ice2")) {
                this.items.put("nevermeltice", 2);
            } else if (this.nameUpper.equals("grass_savanna1")) {
                this.items.put("grass", 4);
            } else if (this.nameUpper.equals("grass_savanna2")) {
                this.items.put("grass", 2);
            } else if (this.nameUpper.equals("bush_savanna1")) {
                this.items.put("log", 1);
                this.items.put("grass", 1);
            } else if (this.nameUpper.equals("tree_savanna1")) {
                this.items.put("log", 4);
            } else if (this.nameUpper.equals("aloe_large1")) {
                this.items.put("log", 1);
                this.items.put("grass", 4);
            } else if (this.nameUpper.equals("tree6")) {
                this.items.put("log", 2);
            } else if (this.nameUpper.contains("bush2_color")) {
                this.items.put("log", 1);
                String[] items = {"black apricorn", "blue apricorn", "green apricorn", "pink apricorn", "red apricorn", "white apricorn", "yellow apricorn"};
                if (Game.staticGame.map.rand.nextInt(2) == 0) {
                    this.items.put(items[Game.staticGame.map.rand.nextInt(items.length)], 1);
                }
            } else if (this.nameUpper.equals("tree2")) {
                this.items.put("log", 2);
                String[] items2 = {"black apricorn", "blue apricorn", "green apricorn", "pink apricorn", "red apricorn", "white apricorn", "yellow apricorn"};
                if (Game.staticGame.map.rand.nextInt(2) == 0) {
                    this.items.put(items2[Game.staticGame.map.rand.nextInt(items2.length)], 2);
                }
            } else if (this.nameUpper.equals("tree4")) {
                this.items.put("log", 2);
                String[] items3 = {"black apricorn", "blue apricorn", "green apricorn", "pink apricorn", "red apricorn", "white apricorn", "yellow apricorn"};
                if (Game.staticGame.map.rand.nextInt(2) == 0) {
                    this.items.put(items3[Game.staticGame.map.rand.nextInt(items3.length)], 2);
                }
            } else if (this.nameUpper.equals("grass_planted")) {
                this.items.put("miracle seed", 1);
            } else if (this.nameUpper.contains("berrytree_")) {
                this.items.put("berry seed", 2);
            }
            if (!this.nameUpper.equals("")) {
                if (!this.nameUpper.contains("floor") && !this.nameUpper.contains("pokeball") && !this.nameUpper.contains("bush") && !this.nameUpper.equals("pokemon_mansion_key") && !this.nameUpper.contains("REGI") && !this.nameUpper.contains("tree") && !this.nameUpper.contains("rock") && !this.nameUpper.equals("grass_planted") && !this.nameUpper.contains("campfire") && !this.nameUpper.contains("fence") && !this.nameUpper.contains("house") && !this.nameUpper.contains("gravestone") && !this.nameUpper.contains("savanna")) {
                    this.items.put("grass", 1);
                    this.items.put("log", 1);
                }
                if (this.nameUpper.equals("rock1") || this.nameUpper.equals("rock1_color")) {
                    this.items.put("hard stone", 1);
                    if (Game.rand.nextInt(10) == 0) {
                        this.items.put("moon stone", 1);
                    }
                } else if (this.nameUpper.equals("gravestone2")) {
                    this.items.put("hard stone", 1);
                    this.items.put("life force", 1);
                } else if (this.nameUpper.equals("rock_volcano1")) {
                    this.items.put("hard stone", 1);
                    if (Game.rand.nextInt(10) == 0) {
                        this.items.put("fire stone", 1);
                    }
                }
            }
        }
        return this.items;
    }

    public String getAttr(String attrName) {
        String[] tokens = this.name.split("_" + attrName);
        String value = tokens[tokens.length - 1];
        if (!value.equals("")) {
            value = value.split("_")[0];
        }
        return value;
    }

    public static Tile get(Network.TileDataBase tileData, Route routeBelongsTo) {
        if (tileData.tileNameUpper.equals("sign1")) {
            return new TrainerTipsTile(tileData.pos.cpy(), routeBelongsTo, tileData.isUnown, tileData.message);
        }
        Tile tile = new Tile(tileData.tileName, tileData.tileNameUpper, tileData.pos.cpy(), true, routeBelongsTo);
        tile.items = tileData.items;
        tile.hasItem = tileData.hasItem;
        tile.hasItemAmount = tileData.hasItemAmount;
        tile.doorTiles = tileData.doorTiles;
        tile.biome = tileData.biome;
        tile.isTorch = tile.items != null && tile.items.containsKey("torch");
        if (tileData instanceof Network.TileData) {
            tile.squishedTiles = ((Network.TileData) tileData).squishedTiles;
        }
        return tile;
    }

    public Tile(String tileName, String nameUpper, Vector2 pos) {
        this(tileName, nameUpper, pos, false);
    }

    public Tile(String tileName, String nameUpper, Vector2 pos, boolean color) {
        this(tileName, nameUpper, pos, color, null);
    }

    public Tile(String tileName, String nameUpper, Vector2 pos, boolean color, Route routeBelongsTo) {
        this.isSolid = false;
        this.isLedge = false;
        this.isWater = false;
        this.isGrass = false;
        this.isTree = false;
        this.isSmashable = false;
        this.isCuttable = false;
        this.isHeadbuttable = false;
        this.hasItemAmount = 0;
        this.isTorch = false;
        this.belowBridge = false;
        this.drawAsTree = false;
        this.drawUpperBelowPlayer = false;
        this.drawSavannaTree = false;
        this.isChimney = false;
        this.squishedTiles = null;
        this.nameUpper = "";
        this.biome = "";
        this.items = null;
        this.isBottomMtnLayer = false;
        this.shoreOcean = null;
        this.shoreTidal = null;
        this.isTidal = false;
        this.isWaterfall = false;
        this.isLava = false;
        this.yOffset = 0;
        init(tileName, nameUpper, pos, color, routeBelongsTo);
    }

    public void init() {
        init(this.name, this.nameUpper, this.position, true, this.routeBelongsTo);
    }

    public void init(String tileName, String nameUpper, Vector2 pos, boolean color, Route routeBelongsTo) {
        Texture playerText;
        Texture playerText2;
        Texture playerText3;
        Texture playerText4;
        Texture playerText5;
        if (Game.staticGame.map != null && !Game.staticGame.map.refreshCache) {
            Game.staticGame.map.refreshCache = true;
        }
        this.isSolid = false;
        this.isLedge = false;
        this.isWater = false;
        this.isGrass = false;
        this.isTree = false;
        this.isSmashable = false;
        this.isCuttable = false;
        this.isHeadbuttable = false;
        this.isTidal = false;
        this.isWaterfall = false;
        this.isLava = false;
        this.drawUpperBelowPlayer = false;
        this.isChimney = false;
        if (tileName.contains("_tidalwater")) {
            this.isTidal = true;
            this.isGrass = true;
        }
        this.overSprite = null;
        this.ledgeDir = null;
        this.name = tileName;
        this.nameUpper = nameUpper;
        this.position = pos;
        this.routeBelongsTo = routeBelongsTo;
        String[] strArr = {this.shoreOcean, this.shoreTidal};
        for (String shoreType : strArr) {
            if (shoreType != null) {
                DynamicTextures.cacheShorelines(shoreType);
            }
        }
        if (tileName.contains("puddle1")) {
            String baseTile = tileName.split("_")[0];
            if (baseTile.equals("sand4")) {
                baseTile = "sand1";
            } else if (baseTile.equals("mountain4")) {
                baseTile = "mountain1";
            }
            DynamicTextures.cachePuddle(tileName, baseTile, getAttr("puddle1"));
            this.sprite = new SmolSprite(DynamicTextures.get(tileName));
            if (this.isTidal) {
                this.sprite = TextureCache.getTileSprite(baseTile);
            }
        } else if (tileName.equals("ground1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground1.png")), 0, 0, 16, 16);
        } else if (tileName.equals("ground2")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground2.png")), 0, 0, 16, 16);
        } else if (tileName.equals("block1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("block1.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("grass1")) {
            this.sprite = TextureCache.getTileSprite("blank2");
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("grass1.png")), 0, 0, 16, 16);
            this.isGrass = true;
        } else if (tileName.equals("grass_planted")) {
            this.sprite = TextureCache.getTileSprite("grass_planted");
        } else if (tileName.equals("grass2")) {
            this.sprite = TextureCache.getTileSprite("grass2_under");
            this.overSprite = TextureCache.getTileSprite("grass2_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("grass3")) {
            this.sprite = TextureCache.getTileSprite("grass3_under");
            this.overSprite = TextureCache.getTileSprite("grass3_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("grass4")) {
            this.sprite = TextureCache.getTileSprite("green1");
            this.overSprite = TextureCache.getTileSprite("grass4_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("grass_sand1")) {
            this.sprite = TextureCache.getTileSprite("sand1");
            this.overSprite = TextureCache.getTileSprite("grass2_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("flower1")) {
            this.sprite = TextureCache.getTileSprite("flower1");
        } else if (tileName.equals("ground3")) {
            this.sprite = TextureCache.getTileSprite("ground3");
        } else if (tileName.equals("mountain1") || tileName.equals("mountain4") || tileName.equals("mountain5")) {
            this.sprite = TextureCache.getTileSprite("mountain1");
        } else if (tileName.equals("mountain2")) {
            this.sprite = TextureCache.getTileSprite("mountain2");
        } else if (tileName.equals("mountain3")) {
            this.sprite = TextureCache.getTileSprite("mountain3");
        } else if (tileName.equals("mountain6")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.contains("mountain")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            if (tileName.contains("left")) {
                this.isLedge = true;
                this.ledgeDir = "left";
            } else if (tileName.contains("right")) {
                this.isLedge = true;
                this.ledgeDir = "right";
            } else if (tileName.contains("top")) {
                this.isLedge = true;
                this.ledgeDir = "up";
            } else if (tileName.contains("bottom")) {
                this.isLedge = true;
                this.ledgeDir = "down";
            } else if (!tileName.contains("inner")) {
                this.isSolid = true;
            }
        } else if (tileName.contains("cave1") || tileName.contains("cave2")) {
            if (tileName.equals("cave1_regi1")) {
                Texture playerText6 = TextureCache.get(Gdx.files.internal("tiles/cave1/" + tileName + ".png"));
                this.sprite = new SmolSpriteProxy(new Color(0.21960784f, 0.21960784f, 0.21960784f, 1.0f), new Color(0.7529412f, 0.5647059f, 0.21960784f, 1.0f), new Color(0.627451f, 0.47058824f, 0.09411765f, 1.0f), playerText6, 0, 0, 16, 16);
                this.sprite = new SmolSpriteProxy(playerText6, 0, 0, 32, 32);
            } else if (tileName.equals("cave1_regi2") || tileName.equals("cave1_regi3")) {
                this.sprite = new SmolSpriteProxy(TextureCache.get(Gdx.files.internal("tiles/cave1/cave1_regi1.png")), 128, 0, 32, 32);
            } else {
                this.sprite = new SmolSpriteProxy(new Color(0.21960784f, 0.21960784f, 0.21960784f, 1.0f), new Color(0.7529412f, 0.5647059f, 0.21960784f, 1.0f), new Color(0.627451f, 0.47058824f, 0.09411765f, 1.0f), TextureCache.get(Gdx.files.internal("tiles/cave1/" + tileName + ".png")), 0, 0, 16, 16);
            }
            if (tileName.contains("up")) {
                this.isLedge = true;
                this.ledgeDir = "up";
            } else if (!tileName.contains("floor") && !tileName.contains("ramp") && !tileName.contains("door")) {
                this.isSolid = true;
            }
            if (this.name.equals("cave1_regipedistal1")) {
                this.overSprite = this.sprite;
                this.sprite = new SmolSpriteProxy(new Color(0.21960784f, 0.21960784f, 0.21960784f, 1.0f), new Color(0.7529412f, 0.5647059f, 0.21960784f, 1.0f), new Color(0.627451f, 0.47058824f, 0.09411765f, 1.0f), TextureCache.get(Gdx.files.internal("tiles/cave1/cave1_up1.png")), 0, 0, 16, 16);
            }
        } else if (tileName.equals("tree_large1")) {
            if (color) {
                this.sprite = TextureCache.getTileSprite("tree_large1_color");
            } else {
                this.sprite = TextureCache.getTileSprite("tree_large1");
            }
            this.isSolid = true;
            this.isCuttable = true;
        } else if (tileName.equals("tree_large2")) {
            this.sprite = TextureCache.getTileSprite("tree_large2");
            this.isSolid = true;
        } else if (tileName.equals("tree_large4")) {
            this.sprite = TextureCache.getTileSprite("tree_large4");
            this.isSolid = true;
        } else if (tileName.equals("tree_large3") || tileName.equals("tree_fairy1") || tileName.equals("tree_fairy2") || tileName.equals("grass_fairy1") || tileName.equals("grass_fairy2") || tileName.equals("grass_fairy3")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            this.isSolid = true;
        } else if (tileName.equals("tree_large1_noSprite")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.isSolid = true;
            this.isCuttable = true;
        } else if (tileName.equals("ledge1_down")) {
            if (color) {
                playerText5 = TextureCache.get(Gdx.files.internal("ledge1_down_color.png"));
            } else {
                playerText5 = TextureCache.get(Gdx.files.internal("ledge1_down.png"));
            }
            this.sprite = new SmolSprite(playerText5, 0, 0, 16, 16);
            this.isLedge = true;
            this.ledgeDir = "down";
        } else if (tileName.contains("ledge2")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            this.isLedge = true;
        } else if (tileName.equals("ledge1_left")) {
            if (color) {
                playerText4 = TextureCache.get(Gdx.files.internal("ledge1_left_color.png"));
            } else {
                playerText4 = TextureCache.get(Gdx.files.internal("ledge1_left.png"));
            }
            this.sprite = new SmolSprite(playerText4, 0, 0, 16, 16);
            this.isLedge = true;
            this.ledgeDir = "left";
        } else if (tileName.equals("ledge1_right")) {
            if (color) {
                playerText3 = TextureCache.get(Gdx.files.internal("ledge1_right_color.png"));
            } else {
                playerText3 = TextureCache.get(Gdx.files.internal("ledge1_right.png"));
            }
            this.sprite = new SmolSprite(playerText3, 0, 0, 16, 16);
            this.isLedge = true;
            this.ledgeDir = "right";
        } else if (tileName.equals("ground2_top")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground2_top.png")), 0, 0, 16, 16);
            this.isLedge = true;
        } else if (tileName.equals("ledge1_corner_bl")) {
            if (color) {
                playerText2 = TextureCache.get(Gdx.files.internal("ledge1_corner_bl_color.png"));
            } else {
                playerText2 = TextureCache.get(Gdx.files.internal("ledge1_corner_bl.png"));
            }
            this.sprite = new SmolSprite(playerText2, 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("ledge1_corner_br")) {
            if (color) {
                playerText = TextureCache.get(Gdx.files.internal("ledge1_corner_br_color.png"));
            } else {
                playerText = TextureCache.get(Gdx.files.internal("ledge1_corner_br.png"));
            }
            this.sprite = new SmolSprite(playerText, 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("ledge2_corner_tl")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ledge2_corner_tl.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("ledge2_corner_tr")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ledge2_corner_tr.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("ledge_grass_ramp")) {
            if (color) {
                this.sprite = TextureCache.getTileSprite("ledge_grass_ramp_color");
            } else {
                this.sprite = TextureCache.getTileSprite("ledge_grass_ramp");
            }
        } else if (tileName.equals("ledge_grass_safari_up")) {
            this.sprite = TextureCache.getTileSprite("ledge_grass_safari_up");
            this.isLedge = true;
            this.ledgeDir = "up";
        } else if (tileName.equals("ledge_grass_down")) {
            if (color) {
                this.sprite = TextureCache.getTileSprite("ledge1_down_color");
            } else {
                this.sprite = TextureCache.getTileSprite("ledge_grass_down");
            }
            this.isLedge = true;
            this.ledgeDir = "down";
        } else if (tileName.equals("ledge_grass_left")) {
            this.sprite = TextureCache.getTileSprite("ledge_grass_left");
            this.isLedge = true;
            this.ledgeDir = "left";
        } else if (tileName.equals("ledge_grass_right")) {
            this.sprite = TextureCache.getTileSprite("ledge_grass_right");
            this.isLedge = true;
            this.ledgeDir = "right";
        } else if (tileName.equals("ledge_grass_inside_tl")) {
            this.sprite = TextureCache.getTileSprite("ledge_grass_inside_tl");
            this.isSolid = true;
        } else if (tileName.equals("ledge_grass_inside_tr")) {
            this.sprite = TextureCache.getTileSprite("ledge_grass_inside_tr");
            this.isSolid = true;
        } else if (tileName.equals("water1")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
        } else if (tileName.equals("water1_ledge1_left")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
            this.overSprite = TextureCache.getTileSprite("water1_ledge1_left");
        } else if (tileName.equals("water1_ledge1_right")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
            this.overSprite = TextureCache.getTileSprite("water1_ledge1_right");
        } else if (tileName.equals("water1_ledge1_tl")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
            this.overSprite = TextureCache.getTileSprite("water1_ledge1_tl");
        } else if (tileName.equals("water1_ledge1_top")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
            this.overSprite = TextureCache.getTileSprite("water1_ledge1_top");
        } else if (tileName.equals("water1_ledge1_tr")) {
            this.sprite = TextureCache.getTileSprite("water1");
            this.isSolid = true;
            this.isWater = true;
            this.overSprite = TextureCache.getTileSprite("water1_ledge1_tr");
        } else if (tileName.equals("grass_short2")) {
            this.sprite = TextureCache.getTileSprite("grass_short2");
        } else if (tileName.equals("grass_short3")) {
            this.sprite = TextureCache.getTileSprite("grass_short3");
        } else if (tileName.equals("warp1_greyed")) {
            this.sprite = TextureCache.getTileSprite("warp1_greyed");
        } else if (tileName.equals("warp1")) {
            this.sprite = TextureCache.getTileSprite("warp1");
        } else if (tileName.equals("raikou_overw1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground1.png")), 0, 0, 16, 16);
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("pokemon/raikou_overw1.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("entei_overw1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground1.png")), 0, 0, 16, 16);
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("pokemon/entei_overw1.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("suicune_overw1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("ground1.png")), 0, 0, 16, 16);
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("pokemon/suicune_overw1.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("mega_gengar_overworld1")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("pokemon/mgengar_overworld1.png")), 0, 0, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("solid")) {
            this.sprite = TextureCache.getTileSprite("qmark_tile1");
            this.isSolid = true;
        } else if (tileName.equals("bush1")) {
            if (color) {
                this.overSprite = TextureCache.getTileSprite("bush2_color");
                this.nameUpper = "bush2_color";
            }
            this.name = "green1";
            this.sprite = TextureCache.getTileSprite("green1");
            this.isSolid = true;
            this.isCuttable = true;
            this.isHeadbuttable = true;
        } else if (tileName.equals("bush2")) {
            this.overSprite = TextureCache.getTileSprite("bush2_color");
            this.sprite = TextureCache.getTileSprite("green1");
            this.isSolid = true;
        } else if (tileName.equals("tree_small1")) {
            this.sprite = TextureCache.getTileSprite("tree_small1");
            this.isSolid = true;
        } else if (tileName.equals("rock1")) {
            this.isSolid = true;
            this.sprite = TextureCache.getTileSprite("sand1");
            this.name = "sand1";
            this.nameUpper = "rock1";
        } else if (tileName.equals("rock2")) {
            this.sprite = TextureCache.getTileSprite("rock2");
            this.isSolid = true;
        } else if (tileName.equals("rock3")) {
            this.sprite = TextureCache.getTileSprite("rock3");
            this.isSolid = true;
        } else if (tileName.equals("rock4")) {
            this.sprite = TextureCache.getTileSprite("rock4");
        } else if (tileName.equals("rock5")) {
            this.sprite = TextureCache.getTileSprite("sand1");
            this.name = "sand1";
            this.nameUpper = tileName;
        } else if (tileName.equals("bridge1_tidalwater")) {
            this.sprite = TextureCache.getTileSprite("bridge1");
            this.isCuttable = true;
            this.isTidal = false;
        } else if (tileName.contains("_tidal")) {
            String name = tileName.split("_")[0];
            if (name.equals("sand4") || name.contains("bridge")) {
                name = "sand1";
            }
            this.sprite = TextureCache.getTileSprite(name);
            if (tileName.contains("_tidalwater")) {
                this.isTidal = true;
                this.isGrass = true;
            }
        } else if (tileName.equals("sand1") || tileName.equals("sand4") || tileName.equals("sand4_tidal")) {
            this.sprite = TextureCache.getTileSprite("sand1");
        } else if (tileName.equals("sand4_black")) {
            this.sprite = TextureCache.getTileSprite("sand4_black");
        } else if (tileName.equals("sand3_black")) {
            this.sprite = TextureCache.getTileSprite("sand3_black");
        } else if (tileName.equals("sand2")) {
            this.sprite = TextureCache.getTileSprite("sand2");
        } else if (tileName.equals("sand3") || tileName.equals("sand3_desertEdge")) {
            this.sprite = TextureCache.getTileSprite("sand3");
        } else if (tileName.equals("path1")) {
            this.sprite = TextureCache.getTileSprite("path1");
        } else if (tileName.equals("green_woodedlake") || tileName.equals("green_deepforest")) {
            this.sprite = TextureCache.getTileSprite("green1");
        } else if (tileName.contains("green")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.contains("flower")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.contains("snow")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            if (tileName.equals("snow3")) {
                this.isGrass = true;
                this.overSprite = this.sprite;
            }
        } else if (tileName.equals("soot1")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            this.isGrass = true;
            this.overSprite = this.sprite;
        } else if (tileName.equals("tree1")) {
            this.sprite = TextureCache.getTileSprite("tree1");
            this.isSolid = true;
        } else if (tileName.equals("tree2")) {
            this.sprite = TextureCache.getTileSprite("green1");
            this.overSprite = TextureCache.getTileSprite("tree2");
            this.name = "green1";
            this.nameUpper = "tree2";
            this.isSolid = true;
            this.isCuttable = true;
            this.isHeadbuttable = true;
        } else if (tileName.equals("tree4")) {
            this.sprite = TextureCache.getTileSprite("snow1");
            this.overSprite = TextureCache.getTileSprite("tree4");
            this.name = "snow1";
            this.nameUpper = "tree4";
            this.isSolid = true;
            this.isHeadbuttable = true;
        } else if (tileName.equals("tree5")) {
            this.sprite = TextureCache.getTileSprite("green1");
            this.overSprite = TextureCache.getTileSprite("tree6");
            this.isSolid = true;
            this.isTree = true;
            this.isHeadbuttable = true;
            this.isCuttable = true;
        } else if (tileName.equals("tree6")) {
            this.sprite = TextureCache.getTileSprite("tree6");
            this.isSolid = true;
            this.isTree = true;
            this.isHeadbuttable = true;
        } else if (tileName.equals("tree7")) {
            this.sprite = TextureCache.getTileSprite("tree7");
            this.isSolid = true;
            this.isTree = true;
            this.isHeadbuttable = true;
        } else if (tileName.equals("aloe_large1")) {
            this.sprite = TextureCache.getTileSprite("aloe_large1");
            this.isSolid = true;
            this.isCuttable = true;
        } else if (tileName.contains("cactus")) {
            TextureCache.get(Gdx.files.internal("tiles/desert6.png"));
            this.sprite = TextureCache.getTileSprite("aloe_large1");
            Texture playerText7 = TextureCache.get(Gdx.files.internal("tiles/" + tileName + ".png"));
            this.overSprite = new SmolSprite(playerText7, 0, 0, 16, 16);
            if (tileName.equals("cactus2") || tileName.equals("cactus3") || tileName.equals("cactus9")) {
                this.overSprite = new SmolSprite(playerText7, 0, 0, 16, 32);
            }
            if (tileName.equals("cactus10")) {
                this.overSprite = new SmolSprite(playerText7, 0, 0, 32, 16);
            }
            if (!tileName.equals("cactus10") && !tileName.equals("cactus7") && !tileName.equals("cactus8") && !tileName.equals("cactus9")) {
                this.name = "desert6";
                this.nameUpper = tileName;
            }
            this.isSolid = true;
            this.isHeadbuttable = true;
        } else if (tileName.contains("ruins")) {
            if (tileName.contains("pillar")) {
                this.sprite = TextureCache.getTileSprite("desert4");
                this.overSprite = TextureCache.getTileSprite(tileName);
                this.isSolid = true;
                this.drawAsTree = true;
            } else if (tileName.contains("floor")) {
                this.sprite = TextureCache.getTileSprite(tileName);
            } else if (tileName.contains("picture")) {
                this.sprite = TextureCache.getTileSprite(tileName);
                this.isSolid = true;
            } else if (tileName.contains("path")) {
                this.sprite = TextureCache.getTileSprite(tileName);
            } else if (tileName.contains("wall")) {
                this.sprite = TextureCache.getTileSprite(tileName);
                this.isSolid = true;
                this.drawAsTree = true;
                this.overSprite = this.sprite;
            } else {
                Texture text = TextureCache.get(Gdx.files.internal("tiles/ruins1_all.png"));
                int offsetX = 8;
                int offsetY = 8;
                if (this.name.contains("E")) {
                    offsetX = 8 - 8;
                }
                if (this.name.contains("W")) {
                    offsetX += 8;
                }
                if (this.name.contains("N")) {
                    offsetY = 8 + 8;
                }
                if (this.name.contains("S")) {
                    offsetY -= 8;
                }
                this.sprite = new SmolSprite(text, offsetX, offsetY, 16, 16);
            }
        } else if (tileName.contains("waterfall") || tileName.contains("lavafall")) {
            this.isWaterfall = true;
            String name2 = "waterfall_sheet2";
            if (tileName.contains("lavafall")) {
                name2 = "lavafall_sheet2";
            }
            Texture text2 = TextureCache.get(Gdx.files.internal("tiles/" + name2 + ".png"));
            int mul = 1;
            if (tileName.contains("inner")) {
                text2 = TextureCache.get(Gdx.files.internal("tiles/" + name2 + "_inner.png"));
                mul = -1;
            }
            int offsetX2 = 16;
            int offsetY2 = 16;
            if (this.name.contains("E")) {
                offsetX2 = 16 - (mul * 16);
            }
            if (this.name.contains("W")) {
                offsetX2 += mul * 16;
            }
            if (this.name.contains("N")) {
                offsetY2 = 16 + (mul * 16);
            }
            if (this.name.contains("S")) {
                offsetY2 -= mul * 16;
            }
            this.sprite = new SmolSprite(text2, offsetX2, offsetY2, 16, 16);
        } else if (tileName.contains("lava")) {
            this.isLava = true;
            Texture text3 = TextureCache.get(Gdx.files.internal("tiles/lava_sheet1.png"));
            int offsetX3 = 16;
            int offsetY3 = 16;
            if (this.name.contains("E")) {
                offsetX3 = 16 + 16;
            }
            if (this.name.contains("W")) {
                offsetX3 -= 16;
            }
            if (this.name.contains("N")) {
                offsetY3 = 16 - 16;
            }
            if (this.name.contains("S")) {
                offsetY3 += 16;
            }
            this.sprite = new SmolSprite(text3, offsetX3, offsetY3, 16, 16);
            this.isSolid = true;
        } else if (tileName.equals("tree_plant1")) {
            this.sprite = new SmolSprite(TextureCache.get(Gdx.files.internal("tiles/green1.png")), 0, 0, 16, 16);
            this.overSprite = new SmolSprite(TextureCache.get(Gdx.files.internal("tiles/buildings/plant1.png")), 0, 0, 16, 32);
            this.isSolid = true;
            this.isTree = true;
        } else if (tileName.equals("pkmnmansion_statue1")) {
            this.sprite = TextureCache.getTileSprite("buildings/pkmnmansion_floor1");
            this.overSprite = TextureCache.getTileSprite("buildings/pkmnmansion_statue1");
            this.isSolid = true;
            this.drawAsTree = true;
        } else if (tileName.equals("pkmnmansion_struct1")) {
            this.sprite = TextureCache.getTileSprite("buildings/pkmnmansion_floor1");
            this.overSprite = TextureCache.getTileSprite("buildings/pkmnmansion_struct1");
            this.isSolid = true;
        } else if (tileName.equals("pkmnmansion_shelf1")) {
            this.sprite = TextureCache.getTileSprite("buildings/pkmnmansion_floor1");
            this.overSprite = TextureCache.getTileSprite("buildings/pkmnmansion_shelf1");
            this.isSolid = true;
            this.drawAsTree = true;
        } else if (tileName.equals("pkmnmansion_shelf1_NS")) {
            this.sprite = TextureCache.getTileSprite("buildings/pkmnmansion_floor1");
            this.overSprite = TextureCache.getTileSprite("buildings/pkmnmansion_shelf1_NS");
            this.isSolid = true;
            this.drawAsTree = true;
        } else if (tileName.equals("water2")) {
            this.sprite = TextureCache.getTileSprite("water2");
            this.isSolid = true;
            this.isWater = true;
        } else if (tileName.equals("water2_edge1")) {
            this.sprite = TextureCache.getTileSprite("water2_edge1");
            this.isSolid = true;
            this.isWater = true;
        } else if (tileName.equals("water3")) {
            this.sprite = TextureCache.getTileSprite("water3");
            this.isSolid = true;
            this.isWater = true;
        } else if (tileName.equals("water5")) {
            this.sprite = TextureCache.getTileSprite("water2");
            this.isSolid = true;
            this.isWater = true;
        } else if (tileName.equals("black1")) {
            this.sprite = TextureCache.getTileSprite("blank3");
            this.isSolid = true;
        } else if (tileName.equals("blank1")) {
            this.sprite = TextureCache.getTileSprite("blank");
        } else if (tileName.equals("campfire1")) {
            this.sprite = TextureCache.getTileSprite("campfire1", 16, 20);
            this.isSolid = true;
        } else if (tileName.equals("fence1")) {
            this.sprite = TextureCache.getTileSprite("fence1");
            this.isSolid = true;
        } else if (tileName.equals("fence2")) {
            this.sprite = TextureCache.getTileSprite("fence2");
            this.isSolid = true;
        } else if (tileName.equals("bridge1_water2_lower")) {
            this.sprite = TextureCache.getTileSprite("water2");
            this.isWater = true;
            this.isSolid = true;
            this.belowBridge = true;
        } else if (tileName.equals("bridge1_water5_lower")) {
            this.sprite = TextureCache.getTileSprite("water2");
            this.isWater = true;
            this.isSolid = true;
            this.belowBridge = true;
        } else if (tileName.contains("bridge")) {
            this.sprite = TextureCache.getTileSprite("bridge1");
            this.isCuttable = true;
        } else if (tileName.equals("sleeping_bag1")) {
            this.sprite = TextureCache.getTileSprite("sleeping_bag1");
        } else if (tileName.equals("house_bed1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_bed1");
            this.isSolid = true;
        } else if (tileName.equals("house_plant1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_plant1");
            this.isSolid = true;
        } else if (tileName.equals("house_plant2")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_plant2");
            this.isSolid = true;
        } else if (tileName.equals("house_gym1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_gym1");
            this.isSolid = true;
        } else if (tileName.equals("house_wardrobe1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_wardrobe1");
            this.isSolid = true;
        } else if (tileName.contains("house_vanity")) {
            this.sprite = TextureCache.getTileSprite("buildings/" + tileName);
            this.isSolid = true;
        } else if (tileName.contains("house_couch1")) {
            this.sprite = TextureCache.getTileSprite("buildings/" + tileName);
            this.isSolid = true;
        } else if (tileName.contains("house_couch")) {
            this.sprite = TextureCache.getTileSprite("buildings/" + tileName);
            this.isSolid = true;
        } else if (tileName.equals("house_shelf1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_shelf1");
            this.isSolid = true;
        } else if (tileName.equals("house_stool1")) {
            this.sprite = TextureCache.getTileSprite("buildings/house_stool1");
        } else if (tileName.equals("torch1")) {
            this.sprite = TextureCache.getTileSprite("torch_sheet1", 16, 20);
        } else if (tileName.contains("desert")) {
            if (tileName.equals("desert2_trapinch_spawn")) {
                tileName = "desert2";
            }
            if (tileName.equals("desert4_isGrass")) {
                tileName = "desert4";
                this.isGrass = true;
            }
            this.sprite = TextureCache.getTileSprite(tileName);
            if (tileName.equals("desert2")) {
                this.isGrass = true;
                this.overSprite = this.sprite;
            }
        } else if (tileName.equals("grass_sand2")) {
            this.sprite = TextureCache.getTileSprite("desert1");
            this.overSprite = TextureCache.getTileSprite("grass2_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("grass_sand3")) {
            this.sprite = TextureCache.getTileSprite("desert6");
            this.overSprite = TextureCache.getTileSprite("grass5_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.equals("grass_graveyard1")) {
            this.sprite = TextureCache.getTileSprite("green11");
            this.overSprite = TextureCache.getTileSprite("grass6_over");
            this.isGrass = true;
            this.isCuttable = true;
        } else if (tileName.contains("house6")) {
            this.sprite = TextureCache.getTileSprite("blank3");
            this.nameUpper = tileName;
        } else if (tileName.contains("house7")) {
            this.sprite = TextureCache.getTileSprite("blank3");
            this.nameUpper = tileName;
        } else if (tileName.contains("house8")) {
            this.sprite = TextureCache.getTileSprite("blank3");
            this.nameUpper = tileName;
        } else if (tileName.contains("house9")) {
            this.sprite = TextureCache.getTileSprite("blank3");
            this.nameUpper = tileName;
        } else if (tileName.contains("potted")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.contains("hole1")) {
            this.sprite = TextureCache.getTileSprite("hole1");
        } else if (tileName.equals("building1_pokecenter1_right")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.isSolid = true;
        } else if (tileName.equals("building1_pokecenter1")) {
            this.sprite = TextureCache.getTileSprite("buildings/building1_pokecenter1", 0, 0, 32, 32);
            this.isSolid = true;
        } else if (tileName.equals("building1_machine2")) {
            this.sprite = TextureCache.getTileSprite("buildings/building1_machine2");
            this.isSolid = true;
        } else if (tileName.equals("pedistal1")) {
            this.nameUpper = this.name;
        } else if (tileName.equals("statue1")) {
            this.sprite = TextureCache.getTileSprite("statue1");
            this.isSolid = true;
        } else if (tileName.contains("gate1")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("building1_fossilreviver1")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.equals("interiorwall1")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.contains("gravestone")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.contains("sign_")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.equals("ledges3_none")) {
            this.sprite = TextureCache.getTileSprite("ledges3_none", 8, 8, 16, 16);
        } else if (tileName.contains("ledges3")) {
            this.sprite = TextureCache.getTileSprite("blank");
            this.nameUpper = tileName;
        } else if (tileName.equals("stalagmite1")) {
            this.sprite = TextureCache.getTileSprite("stalagmite1");
        } else if (tileName.contains("_savanna")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            if (tileName.equals("grass_savanna1")) {
                this.overSprite = this.sprite;
                this.sprite = TextureCache.getTileSprite("green_savanna1");
                this.isGrass = true;
                this.isCuttable = true;
            } else if (tileName.equals("grass_savanna2")) {
                this.overSprite = this.sprite;
                this.sprite = TextureCache.getTileSprite("green_savanna1");
                this.isGrass = true;
                this.isCuttable = true;
            }
        } else if (tileName.contains("ice")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("water6")) {
            this.sprite = TextureCache.getTileSprite(tileName);
            this.isWater = true;
        } else if (tileName.equals("volcano1") || tileName.equals("volcano2")) {
            this.sprite = TextureCache.getTileSprite("volcano1");
        } else if (tileName.equals("volcano3")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("warp_tile1")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("chest1")) {
            this.sprite = TextureCache.getTileSprite(tileName, 16, 32);
        } else if (tileName.equals("stairs_up1")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("stairs_down1")) {
            this.sprite = TextureCache.getTileSprite(tileName);
        } else if (tileName.equals("ball_kiln1")) {
            this.sprite = TextureCache.getTileSprite(tileName, 16, 24);
        } else {
            this.sprite = TextureCache.getTileSprite("buildings/" + tileName, 16, 16);
            if (!tileName.contains("door") && !tileName.contains("floor") && !tileName.contains("rug") && !tileName.contains("__off") && !tileName.contains("carpet") && !tileName.contains("cables")) {
                this.isSolid = true;
            }
        }
        if (tileName.contains("pkmnmansion_floor")) {
            this.isGrass = true;
        }
        if (!this.nameUpper.equals("")) {
            if (this.nameUpper.contains("REGI")) {
                Texture text4 = TextureCache.get(Gdx.files.internal("tiles/cave1/overworld2.png"));
                if (this.nameUpper.equals("REGIDRAGO")) {
                    this.overSprite = new SmolSprite(text4, 16, 0, 16, 16);
                } else if (this.nameUpper.equals("REGIELEKI")) {
                    this.overSprite = new SmolSprite(text4, 32, 0, 16, 16);
                } else if (this.nameUpper.equals("REGICE")) {
                    this.overSprite = new SmolSprite(text4, 48, 0, 16, 16);
                } else if (this.nameUpper.equals("REGIROCK")) {
                    this.overSprite = new SmolSprite(text4, 64, 0, 16, 16);
                } else if (this.nameUpper.equals("REGISTEEL")) {
                    this.overSprite = new SmolSprite(text4, 80, 0, 16, 16);
                }
            } else if (this.nameUpper.contains("ledges3")) {
                String name3 = "ledges3";
                if (this.nameUpper.contains("snow")) {
                    name3 = "ledges3snow";
                } else if (this.nameUpper.contains("volcano")) {
                    name3 = "ledges3volcano";
                }
                if (this.nameUpper.contains("inner")) {
                    name3 = name3 + "_inner";
                } else if (this.nameUpper.contains("none")) {
                    name3 = name3 + "_none";
                }
                int offsetX4 = 8;
                int offsetY4 = 8;
                int numDirs = 0;
                String ledgeDir = "left";
                if (this.nameUpper.contains("E")) {
                    offsetX4 = 8 - 8;
                    ledgeDir = "left";
                    numDirs = 0 + 1;
                }
                if (this.nameUpper.contains("W")) {
                    offsetX4 += 8;
                    ledgeDir = "right";
                    numDirs++;
                }
                if (this.nameUpper.contains("N")) {
                    offsetY4 = 8 + 8;
                    ledgeDir = "down";
                    numDirs++;
                }
                if (this.nameUpper.contains("S")) {
                    offsetY4 -= 8;
                    ledgeDir = "up";
                    numDirs++;
                }
                this.isLedge = true;
                this.isSolid = false;
                if (numDirs == 1) {
                    this.ledgeDir = ledgeDir;
                } else if (!this.nameUpper.contains("inner")) {
                    this.isSolid = true;
                }
                this.drawUpperBelowPlayer = true;
                this.overSprite = TextureCache.getTileSprite(name3, offsetX4, offsetY4, 16, 16);
            } else if (this.nameUpper.contains("house6")) {
                String name4 = "house6";
                if (this.nameUpper.contains("roof")) {
                    name4 = name4 + "_roof";
                }
                if (this.nameUpper.contains("inner")) {
                    name4 = name4 + "_inner";
                }
                if (this.nameUpper.contains("door") || this.nameUpper.contains("left") || this.nameUpper.contains("middle") || this.nameUpper.contains("right")) {
                    this.overSprite = TextureCache.getTileSprite("buildings/" + this.nameUpper.replace("chimney", ""), 0, 0, 16, 16);
                } else {
                    String name5 = "buildings/" + name4 + "_all";
                    int offsetX5 = 8;
                    int offsetY5 = 8;
                    if (this.nameUpper.contains("E")) {
                        offsetX5 = 8 - 8;
                    }
                    if (this.nameUpper.contains("W")) {
                        offsetX5 += 8;
                    }
                    if (this.nameUpper.contains("N")) {
                        offsetY5 = 8 + 8;
                    }
                    if (this.nameUpper.contains("S")) {
                        offsetY5 -= 8;
                    }
                    this.overSprite = TextureCache.getTileSprite(name5, offsetX5, offsetY5, 16, 16);
                }
            } else if (this.nameUpper.contains("house7_roof")) {
                this.overSprite = TextureCache.getTileSprite("house7_all", 16, 16, 16, 16);
                String[] exts = this.nameUpper.split("_");
                if (exts.length > 1) {
                    String ext = exts[exts.length - 1];
                    if (ext.equals("E")) {
                        this.overSprite.setRegion(0, 0, 16, 16);
                    } else if (ext.equals("EW")) {
                        this.overSprite.setRegion(16, 0, 16, 16);
                    } else if (ext.equals("SE")) {
                        this.overSprite.setRegion(64, 0, 16, 16);
                    } else if (ext.equals("W")) {
                        this.overSprite.setRegion(48, 0, 16, 16);
                    } else if (ext.equals("SW")) {
                        this.overSprite.setRegion(96, 0, 16, 16);
                    } else if (ext.equals("NE")) {
                        this.overSprite.setRegion(64, 16, 16, 16);
                    } else if (ext.equals("NEW") || ext.equals("N")) {
                        this.overSprite.setRegion(80, 16, 16, 16);
                    } else if (ext.equals("NW")) {
                        this.overSprite.setRegion(96, 16, 16, 16);
                    } else if (ext.equals("NSE")) {
                        this.overSprite.setRegion(112, 0, 16, 16);
                    } else if (ext.equals("S") || ext.equals("SEW")) {
                        this.overSprite.setRegion(80, 0, 16, 16);
                    } else if (ext.equals("NSEW")) {
                        this.overSprite.setRegion(128, 0, 16, 16);
                    } else if (ext.equals("NSW")) {
                        this.overSprite.setRegion(144, 0, 16, 16);
                    }
                }
            } else if (this.nameUpper.contains("house7")) {
                this.overSprite = TextureCache.getTileSprite("house7_all", 176, 16, 16, 16);
                String[] exts2 = this.nameUpper.split("_");
                if (exts2.length > 1) {
                    String ext2 = exts2[exts2.length - 1];
                    if (this.nameUpper.contains("door")) {
                        this.overSprite.setRegion(WinError.ERROR_META_EXPANSION_TOO_LONG, 16, 16, 16);
                    } else if (ext2.equals("E")) {
                        this.overSprite.setRegion(0, 16, 16, 16);
                    } else if (ext2.equals("SE")) {
                        this.overSprite.setRegion(16, 16, 16, 16);
                    } else if (ext2.equals("W")) {
                        this.overSprite.setRegion(48, 16, 16, 16);
                    } else if (ext2.equals("SW")) {
                        this.overSprite.setRegion(32, 16, 16, 16);
                    } else if (ext2.equals("NE")) {
                        this.overSprite.setRegion(160, 16, 16, 16);
                    } else if (ext2.equals("NEW") || ext2.equals("N")) {
                        this.overSprite.setRegion(176, 16, 16, 16);
                    } else if (ext2.equals("NW")) {
                        this.overSprite.setRegion(192, 16, 16, 16);
                    } else if (ext2.equals("NSE")) {
                        this.overSprite.setRegion(160, 0, 16, 16);
                    } else if (ext2.equals("NSEW")) {
                        this.overSprite.setRegion(176, 0, 16, 16);
                    } else if (ext2.equals("S") || ext2.equals("SEW")) {
                        this.overSprite.setRegion(32, 0, 16, 16);
                    } else if (ext2.equals("NSW")) {
                        this.overSprite.setRegion(192, 0, 16, 16);
                    }
                }
            } else if (this.nameUpper.contains("house8")) {
                String name6 = "house8";
                if (this.nameUpper.contains("roof")) {
                    name6 = name6 + "_roof";
                }
                if (this.nameUpper.contains("door") || this.nameUpper.contains("left") || this.nameUpper.contains("middle") || this.nameUpper.contains("right")) {
                    this.overSprite = TextureCache.getTileSprite("buildings/" + this.nameUpper.replace("chimney", ""), 0, 0, 16, 16);
                } else {
                    String name7 = "buildings/" + name6 + "_all";
                    int offsetX6 = 16;
                    int offsetY6 = 16;
                    if (this.nameUpper.contains("E")) {
                        offsetX6 = 16 - 16;
                    }
                    if (this.nameUpper.contains("W")) {
                        offsetX6 += 16;
                    }
                    if (this.nameUpper.contains("N")) {
                        offsetY6 = 16 + 16;
                    }
                    if (this.nameUpper.contains("S")) {
                        offsetY6 -= 16;
                    }
                    if (!this.nameUpper.contains("roof") && !this.nameUpper.contains("S")) {
                        this.yOffset = 4;
                    }
                    this.overSprite = TextureCache.getTileSprite(name7, offsetX6, offsetY6, 16, 16 + this.yOffset);
                }
            } else if (this.nameUpper.contains("house9")) {
                String name8 = "house9";
                int scale = 8;
                if (this.nameUpper.contains("roof")) {
                    name8 = name8 + "_roof";
                    scale = 16;
                }
                if (this.nameUpper.contains("door") || this.nameUpper.contains("left") || this.nameUpper.contains("middle") || this.nameUpper.contains("right")) {
                    this.overSprite = TextureCache.getTileSprite("buildings/" + this.nameUpper.replace("chimney", ""), 0, 0, 16, 16);
                } else {
                    String name9 = "buildings/" + name8 + "_all";
                    int offsetX7 = scale;
                    int offsetY7 = scale;
                    if (this.nameUpper.contains("E")) {
                        offsetX7 -= scale;
                    }
                    if (this.nameUpper.contains("W")) {
                        offsetX7 += scale;
                    }
                    if (this.nameUpper.contains("N")) {
                        offsetY7 += scale;
                    }
                    if (this.nameUpper.contains("S")) {
                        offsetY7 -= scale;
                    }
                    this.overSprite = TextureCache.getTileSprite(name9, offsetX7, offsetY7, 16, 16);
                }
            } else if (this.nameUpper.contains("house_bed1colored")) {
                DynamicTextures.cacheColoredHouseBed(this.nameUpper);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
            } else if (this.nameUpper.contains("house") && !this.nameUpper.contains("|")) {
                String name10 = this.nameUpper;
                if (this.nameUpper.contains("house5")) {
                    name10 = name10.replace("exteriorwindows", "").replace("chimney", "");
                }
                this.overSprite = TextureCache.getTileSprite("buildings/" + name10, 0, 0, 16, 16);
            } else if (this.nameUpper.equals("pedistal1") || this.nameUpper.equals("ruins_statue1") || this.nameUpper.equals("statue1")) {
                this.overSprite = TextureCache.getTileSprite(this.nameUpper, 0, 0, 16, 32);
                this.drawAsTree = true;
            } else if (this.nameUpper.contains("building1_fossilreviver1")) {
                this.overSprite = TextureCache.getTileSprite("buildings/building1_pc1", 0, 0, 16, 24);
            } else if (this.nameUpper.equals("solid")) {
                this.overSprite = null;
            } else if (this.nameUpper.equals("onpress_above")) {
                this.overSprite = null;
            } else if (this.nameUpper.equals("onpress_left")) {
                this.overSprite = null;
            } else if (this.nameUpper.contains("revived")) {
                this.overSprite = null;
            } else if (this.nameUpper.contains("volcarona")) {
                this.overSprite = null;
            } else if (this.nameUpper.contains("spiritomb")) {
                this.overSprite = null;
            } else if (this.nameUpper.contains("hole1_water")) {
                DynamicTextures.cacheWaterHole(this.nameUpper);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
            } else if (this.nameUpper.contains("hole1")) {
                DynamicTextures.cacheHole(this.nameUpper);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
            } else if (this.nameUpper.contains("interiorwall1")) {
                DynamicTextures.cacheInteriorWall(this.nameUpper);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
            } else if (this.nameUpper.contains("_cracked")) {
                this.overSprite = TextureCache.getTileSprite("desert4_cracked", 0, 0, 16, 16);
            } else if (this.nameUpper.equals("tree_large1")) {
                this.overSprite = TextureCache.getTileSprite("tree_large1_color", 0, 0, 32, 32);
            } else if (this.nameUpper.equals("tree_large2") || this.nameUpper.equals("tree_large3")) {
                this.overSprite = TextureCache.getTileSprite(this.nameUpper);
            } else if (this.nameUpper.contains("_savanna")) {
                this.overSprite = TextureCache.getTileSprite(this.nameUpper);
                if (this.nameUpper.contains("tree")) {
                    this.drawUpperBelowPlayer = true;
                    this.drawSavannaTree = true;
                } else if (this.nameUpper.contains("bush")) {
                    this.isCuttable = true;
                } else if (this.nameUpper.contains("grass")) {
                    this.isGrass = true;
                }
            } else if (this.nameUpper.contains("pokedoll1")) {
                this.overSprite = TextureCache.getTileSprite("pokedoll1", 0, 0, 16, 16);
            } else if (this.nameUpper.contains("waterfall") || this.nameUpper.contains("lavafall")) {
                this.isWaterfall = true;
                String name11 = "waterfall_sheet2";
                if (this.nameUpper.contains("lavafall")) {
                    name11 = "lavafall_sheet2";
                }
                Texture text5 = TextureCache.get(Gdx.files.internal("tiles/" + name11 + ".png"));
                int mul2 = 1;
                if (this.nameUpper.contains("inner")) {
                    text5 = TextureCache.get(Gdx.files.internal("tiles/" + name11 + "_inner.png"));
                    mul2 = -1;
                }
                int offsetX8 = 16;
                int offsetY8 = 16;
                if (this.nameUpper.contains("E")) {
                    offsetX8 = 16 - (mul2 * 16);
                }
                if (this.nameUpper.contains("W")) {
                    offsetX8 += mul2 * 16;
                }
                if (this.nameUpper.contains("N")) {
                    offsetY8 = 16 + (mul2 * 16);
                }
                if (this.nameUpper.contains("S")) {
                    offsetY8 -= mul2 * 16;
                }
                this.sprite = new SmolSprite(text5, offsetX8, offsetY8, 16, 16);
                this.overSprite = this.sprite;
            } else if (this.nameUpper.contains("berrytree_")) {
                String name12 = "berrytree_" + this.nameUpper.split("_")[1];
                int offsetX9 = 0;
                if (this.nameUpper.contains("full")) {
                    offsetX9 = 32;
                } else if (this.nameUpper.contains("empty")) {
                    offsetX9 = 64;
                }
                this.overSprite = TextureCache.getTileSprite(name12, offsetX9, 0, 16, 32);
                this.isCuttable = true;
            } else if (this.nameUpper.contains("pkmnmansion")) {
                this.overSprite = TextureCache.getTileSprite("buildings/" + this.nameUpper, 0, 0, 16, 16);
            } else {
                this.overSprite = TextureCache.getTileSprite(this.nameUpper, 0, 0, 16, 16);
            }
            if (this.nameUpper.contains("house") && this.nameUpper.contains("exteriorwindows")) {
                DynamicTextures.cacheHouseWithWindow(this.nameUpper, this.overSprite);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
                this.overSprite.setRegionHeight(this.overSprite.getRegionHeight() + this.yOffset);
            } else if (this.nameUpper.contains("house") && this.nameUpper.contains("chimney")) {
                this.isChimney = true;
                DynamicTextures.cacheHouseWithChimney(this.nameUpper, this.overSprite);
                this.overSprite = new SmolSprite(DynamicTextures.get(this.nameUpper));
            }
            if (this.nameUpper.equals("house_couch1")) {
                this.overSprite.setRegion(0, 0, 32, 16);
                this.drawSavannaTree = true;
            } else if (this.nameUpper.contains("house_couch")) {
                this.overSprite.setRegion(0, 0, 16, 32);
            } else if (this.nameUpper.contains("ball_kiln1")) {
                this.overSprite.setRegion(0, 0, 16, 24);
            } else if (this.nameUpper.equals("campfire1")) {
                this.overSprite.setRegion(0, 0, 16, 20);
            } else if (this.nameUpper.equals("ice2_pit2")) {
                this.overSprite.setRegion(0, 0, 32, 32);
                this.drawSavannaTree = true;
            }
            if (this.nameUpper.contains("house_bed1") || this.nameUpper.contains("tree2") || this.nameUpper.contains("tree4") || this.nameUpper.contains("tree6") || this.nameUpper.contains("tree7") || this.nameUpper.contains("tree8") || this.nameUpper.contains("house_plant1") || this.nameUpper.contains("house_plant2") || this.nameUpper.contains("house_gym1") || this.nameUpper.contains("house_wardrobe1") || this.nameUpper.contains("house_vanity") || this.nameUpper.contains("cactus2") || this.nameUpper.contains("cactus3") || this.nameUpper.contains("cactus9") || this.nameUpper.contains("house_shelf1")) {
                this.overSprite.setRegion(0, 0, 16, 32);
            }
            if (this.nameUpper.equals("cactus10")) {
                this.overSprite.setRegion(0, 0, 32, 16);
                this.drawSavannaTree = true;
            }
            if (this.nameUpper.equals("aloe_large1")) {
                this.overSprite.setRegion(0, 0, 32, 32);
                this.drawSavannaTree = true;
            }
            if (this.nameUpper.equals("chest1")) {
                this.overSprite.setRegion(0, 0, 16, 32);
            }
            if (!this.nameUpper.contains("door") && !this.nameUpper.contains("floor") && !this.nameUpper.contains("tree_planted") && !this.nameUpper.equals("berry_planted") && !this.nameUpper.contains("stool") && !this.nameUpper.contains("gate") && !this.nameUpper.equals("grass_planted") && !this.nameUpper.contains("_cracked") && !this.nameUpper.contains("ledges3") && !this.nameUpper.contains("warp_tile") && !this.nameUpper.contains("waterfall") && !this.nameUpper.contains("grass_savanna")) {
                this.isSolid = true;
            }
            if (this.nameUpper.contains("cactus1") || this.nameUpper.contains("cactus2")) {
                this.isHeadbuttable = true;
            }
            if (!this.nameUpper.contains("floor") && !this.nameUpper.contains("pokeball") && !this.nameUpper.contains("bush") && !this.nameUpper.equals("pokemon_mansion_key") && !this.nameUpper.contains("REGI") && !this.nameUpper.contains("tree") && !this.nameUpper.contains("rock") && !this.nameUpper.contains("ledges3") && !this.nameUpper.contains("onpress") && !this.nameUpper.contains("waterfall") && !this.nameUpper.contains("stairs_down") && !this.nameUpper.contains("hole") && !this.nameUpper.contains("cracked") && !this.nameUpper.equals("pot1") && !this.nameUpper.contains("ultraball") && !this.nameUpper.contains("rubble") && !this.nameUpper.contains("odd_keystone") && !this.nameUpper.contains("pokedoll") && !this.nameUpper.contains("building1_fossilreviver1") && !this.nameUpper.contains("pkmnmansion") && !this.nameUpper.equals("solid")) {
                this.isCuttable = true;
            }
            if (this.nameUpper.contains("bush2_color") || this.nameUpper.equals("tree2") || this.nameUpper.equals("tree6") || this.nameUpper.equals("tree7") || this.nameUpper.equals("tree8") || this.nameUpper.equals("tree9") || this.nameUpper.equals("tree4")) {
                this.isHeadbuttable = true;
                this.isCuttable = true;
            }
            if (this.nameUpper.equals("tree_savanna1")) {
                this.isCuttable = true;
            }
            if (this.nameUpper.equals("pokeball1")) {
                this.isSolid = true;
                this.hasItem = "poké ball";
                this.hasItemAmount = 1;
            } else if (this.nameUpper.equals("ultraball1")) {
                this.isSolid = true;
                this.hasItem = "ultra ball";
                this.hasItemAmount = 1;
            }
            if (this.nameUpper.equals("pokemon_mansion_key")) {
                this.isSolid = true;
                this.hasItem = "secret key";
                this.hasItemAmount = 1;
            }
            if (this.nameUpper.contains("stairs")) {
                this.isSolid = false;
                this.isGrass = false;
            }
            if (this.nameUpper.equals("mewtwo_overworld_hidden")) {
                this.isSolid = false;
            }
            if (this.nameUpper.equals("sign1")) {
                this.isCuttable = false;
            }
            if (this.nameUpper.equals("rock1") || this.nameUpper.equals("rock1_color") || this.nameUpper.equals("rock5") || this.nameUpper.equals("rock_volcano1") || this.nameUpper.contains("gravestone")) {
                this.isSmashable = true;
                this.isCuttable = false;
            }
            if (this.nameUpper.equals("rock_ice2")) {
                this.isSmashable = true;
                this.isCuttable = false;
            }
            if (this.nameUpper.contains("fence")) {
                if (this.nameUpper.equals("fence1") || this.nameUpper.equals("fence2")) {
                    this.isLedge = true;
                    this.ledgeDir = "down";
                } else if (this.nameUpper.equals("fence1_NS") || this.nameUpper.equals("fence2_NS")) {
                    this.isLedge = true;
                    this.ledgeDir = "left";
                }
            }
            if (this.nameUpper.contains("stairs") || this.nameUpper.contains("door") || this.nameUpper.contains("_cracked") || this.nameUpper.equals("grass_planted") || this.nameUpper.contains("warp_tile") || this.nameUpper.contains("stool")) {
                this.drawUpperBelowPlayer = true;
            }
            if (this.nameUpper.contains("warp_tile")) {
                DrawMiniMap.warpTiles.put(this.position.cpy(), this);
            }
        }
        if (this.overSprite != null && !this.nameUpper.contains("tree_planted") && (this.name.contains("tree") || this.nameUpper.contains("tree") || this.nameUpper.contains("house_gym") || this.nameUpper.contains("house_plant") || this.nameUpper.contains("cactus2") || this.nameUpper.equals("cactus9") || this.nameUpper.equals("building1_fossilreviver1") || this.nameUpper.contains("house_shelf") || this.nameUpper.contains("interiorwall") || this.nameUpper.contains("house_vanity") || this.nameUpper.contains("ball_kiln") || this.nameUpper.contains("pkmnmansion_statue1") || this.nameUpper.contains("pkmnmansion_shelf1") || this.nameUpper.equals("rock1_color") || this.nameUpper.contains("house_wardrobe"))) {
            this.drawAsTree = true;
        }
        this.sprite.setPosition(pos.x, pos.y);
        if (this.overSprite != null) {
            this.overSprite.setPosition(pos.x, pos.y);
            if (this.nameUpper.equals("rock1_color")) {
                this.overSprite.setPosition(pos.x, pos.y + 4.0f);
            }
            if (this.nameUpper.equals("tree_savanna1")) {
                this.overSprite.setPosition(pos.x - 16.0f, pos.y);
            }
        }
        if (this.items != null && this.items.containsKey("torch")) {
            this.isTorch = true;
        }
        if (this.belowBridge) {
            this.isSolid = true;
        }
        if (this.routeBelongsTo == null) {
            return;
        }
        if (this.routeBelongsTo.name.equals("wooded_lake1") || this.routeBelongsTo.name.equals("deep_forest")) {
            String name13 = this.name + "_darker";
            DynamicTextures.cacheDarkerTile(name13, this.sprite);
            this.sprite.setRegion(DynamicTextures.get(name13));
        }
    }

    public Tile(String tileName, Vector2 pos) {
        this(tileName, "", pos);
    }

    public Tile(String tileName, Vector2 pos, boolean color) {
        this(tileName, "", pos, color, null);
    }

    public Tile(String tileName, Vector2 pos, boolean color, Route routeBelongsTo) {
        this(tileName, "", pos, color, routeBelongsTo);
    }

    public boolean isSign() {
        return this.nameUpper.equals("gravestone3") || this.nameUpper.equals("sign_built1") || this.nameUpper.equals("sign_desert1") || this.nameUpper.equals("warp_tile1");
    }

    public boolean isWall() {
        return !this.nameUpper.contains("roof");
    }

    public boolean isWall2() {
        return !this.nameUpper.contains("gate") && !this.nameUpper.contains("fence") && !this.nameUpper.contains("roof");
    }

    public boolean is(String name) {
        return this.name.contains(name) || this.nameUpper.contains(name);
    }

    public String ledgeDir() {
        if (this.ledgeDir == null) {
            return "";
        }
        return this.ledgeDir;
    }

    public void updateMiniMap(Game game) {
        int regionHeight;
        int regionWidth;
        int bottom;
        int left;
        Pixmap currPixmap;
        if (!(this.name.equals("tree_large1_noSprite") || this.name.equals("blank1"))) {
            if (this.overSprite != null) {
                currPixmap = this.overSprite.getPixmap();
                left = this.overSprite.getRegionX();
                bottom = this.overSprite.getRegionY();
                regionWidth = this.overSprite.getRegionWidth();
                regionHeight = this.overSprite.getRegionHeight();
            } else {
                currPixmap = this.sprite.getPixmap();
                left = this.sprite.getRegionX();
                bottom = this.sprite.getRegionY();
                regionWidth = this.sprite.getRegionWidth();
                regionHeight = this.sprite.getRegionHeight();
            }
            int offset = 7;
            if (this.name.contains("grass")) {
                offset = 4;
            } else if (this.name.equals("tree_large1")) {
                offset = 6;
            }
            int x = ((int) (this.position.x - game.map.bottomLeft.x)) / 8;
            int y = ((int) (game.map.topRight.y - this.position.y)) / 8;
            int offsetY = ((regionHeight / 16) - 1) * 2;
            for (int m = 0; m * 16 < regionWidth; m++) {
                for (int n = 0; n * 16 < regionHeight; n++) {
                    Game.staticGame.map.minimap.drawPixel(x + (m * 2), (y + (n * 2)) - offsetY, currPixmap.getPixel((m * 16) + offset + left, (n * 16) + offset + bottom));
                    Game.staticGame.map.minimap.drawPixel(x + (m * 2) + 1, (y + (n * 2)) - offsetY, currPixmap.getPixel(((((m + 1) * 16) - 1) - offset) + left, (n * 16) + offset + bottom));
                    Game.staticGame.map.minimap.drawPixel(x + (m * 2), ((y + (n * 2)) + 1) - offsetY, currPixmap.getPixel((m * 16) + offset + left, ((((n + 1) * 16) - 1) - offset) + bottom));
                    Game.staticGame.map.minimap.drawPixel(x + (m * 2) + 1, ((y + (n * 2)) + 1) - offsetY, currPixmap.getPixel(((((m + 1) * 16) - 1) - offset) + left, ((((n + 1) * 16) - 1) - offset) + bottom));
                }
            }
        }
    }

    public void guessBiomeType() {
        if (this.name.contains("sand")) {
            this.biome = "beach";
            this.routeBelongsTo = new Route("beach2", 22);
        } else if (this.name.contains("desert")) {
            this.biome = "desert";
            this.routeBelongsTo = new Route("desert1", 22);
        } else if (this.name.contains("mountain")) {
            this.biome = "mountain";
            this.routeBelongsTo = new Route("mountain1", 22);
        } else if (this.name.contains("snow")) {
            this.biome = "tundra";
            this.routeBelongsTo = new Route("snow1", 22);
        } else if (this.name.contains("volcano")) {
            this.biome = "volcano";
            this.routeBelongsTo = new Route("volcano1", 22);
        } else if (this.name.contains("graveyard") || this.name.equals("green9") || this.name.equals("green10") || this.name.equals("green11") || this.name.equals("green12")) {
            this.biome = "graveyard";
            this.routeBelongsTo = new Route("graveyard1", 22);
        } else if (this.name.contains("savanna")) {
            this.biome = "savanna";
            this.routeBelongsTo = new Route("savanna2", 22);
        } else if (this.name.contains("green")) {
            this.biome = "savanna";
            this.routeBelongsTo = new Route("forest1", 22);
        }
    }

    public void pickUpItem(Player player) {
        if (!this.nameUpper.contains("hole")) {
            this.nameUpper = "";
            init();
        }
        int amount = this.hasItemAmount;
        if (player.hasItem(this.hasItem)) {
            amount += player.getItemAmount(this.hasItem).intValue();
        }
        player.setItemAmount(this.hasItem, amount);
        this.hasItem = null;
        this.hasItemAmount = 0;
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Tile$PutTile.class */
    public class PutTile extends Action {
        Tile tile;
        Vector2 pos;

        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public PutTile(Tile tile, Vector2 pos, Action nextAction) {
            super(new Object[0]);
            Tile.this = this$0;
            this.tile = tile;
            this.pos = pos;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            game.map.overworldTiles.put(this.pos.cpy(), this.tile);
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Tile$SetSignText.class */
    public class SetSignText extends Action {
        Color prevColor = new Color();
        int avatarAnimCounter = 0;
        ArrayList<Character> text = new ArrayList<>();
        int backspaceTimer = 0;
        public boolean done = false;
        public boolean disabled = false;
        Texture bgTexture = TextureCache.get(Gdx.files.internal("battle/battle_bg3.png"));

        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public SetSignText(String existingText, Action nextAction) {
            super(new Object[0]);
            Tile.this = this$0;
            if (existingText != null) {
                for (char c : existingText.toCharArray()) {
                    this.text.add(Character.valueOf(c));
                }
            }
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Layer getLayer() {
            return Layer.gui_106;
        }

        @Override // com.corona.game.Action
        public void firstStep(Game game) {
            game.insertAction(new DisplayText(game, "Press Enter to set text", (String) null, true, false, (Action) null));
            Gdx.input.setInputProcessor(new InputAdapter() { // from class: com.corona.game.Tile.SetSignText.1
                @Override // com.badlogic.gdx.InputAdapter, com.badlogic.gdx.InputProcessor
                public boolean keyTyped(char character) {
                    TextField.updateField(character, SetSignText.this.text, 100, true);
                    return false;
                }
            });
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            this.prevColor.set(game.uiBatch.getColor());
            game.uiBatch.setColor(1.0f, 1.0f, 1.0f, 1.0f);
            game.uiBatch.draw(this.bgTexture, -8.0f, -8.0f);
            int i = 0;
            int j = 0;
            int k = 0;
            while (k < this.text.size()) {
                char character = this.text.get(k).charValue();
                if (character == ' ' && k + 1 < this.text.size()) {
                    int length = 1;
                    char nextChar = this.text.get(k + 1).charValue();
                    while (nextChar != ' ' && k + length < this.text.size()) {
                        length++;
                        nextChar = this.text.get(k + length).charValue();
                    }
                    if (i + length > 20 && j < 5) {
                        i = -1;
                        j++;
                    }
                }
                Sprite letterSprite = game.textDict.get(Character.valueOf(character));
                letterSprite.setPosition((float) (8 * i), (float) (128 - (16 * j)));
                letterSprite.draw(game.uiBatch);
                i++;
                if (i > 20) {
                    i = 0;
                    j++;
                }
                k++;
            }
            if (this.avatarAnimCounter >= 12) {
                game.uiBatch.draw(game.textDict.get('_'), (float) (8 * i), (float) (128 - (16 * j)));
            }
            game.uiBatch.setColor(this.prevColor);
            if (this.done) {
                game.actionStack.remove(this);
            }
            if (!this.disabled) {
                if (!Gdx.input.isKeyPressed(67)) {
                    this.backspaceTimer = 0;
                } else if (this.backspaceTimer < 30) {
                    this.backspaceTimer++;
                }
                if ((this.backspaceTimer >= 30 || Gdx.input.isKeyJustPressed(67)) && this.text.size() > 0) {
                    this.text.remove(this.text.size() - 1);
                }
                if (Gdx.input.isKeyJustPressed(66)) {
                    Gdx.input.setInputProcessor(null);
                    this.disabled = true;
                    String allText = "";
                    Iterator<Character> it = this.text.iterator();
                    while (it.hasNext()) {
                        allText = allText + it.next().charValue();
                    }
                    game.insertAction(new DisplayText.Clear(game, new WaitFrames(game, 3, new DisplayText(game, "Keep changes?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 3, new SetField(Tile.this, "hasItem", allText, new PlayMusic("coin1", 0.6f, new WaitFrames(game, 10, new SetField(this, "done", true, new SetField(game, "playerCanMove", true, null))))))), new DisplayText.Clear(game, new WaitFrames(game, 10, new SetField(this, "done", true, new SetField(game, "playerCanMove", true, null)))))))));
                }
                this.avatarAnimCounter--;
                if (this.avatarAnimCounter <= 0) {
                    this.avatarAnimCounter = 24;
                }
            }
        }
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Tile$Moving.class */
    public class Moving extends Action {
        int timer = 0;
        Tile target;
        Vector2 currPos;
        Vector2 offset;
        SmolSprite overSprite;

        /* JADX INFO: 'super' call moved to the top of the method (can break code semantics) */
        public Moving(Tile target, Vector2 position, Action nextAction) {
            super(new Object[0]);
            Tile.this = this$0;
            this.offset = new Vector2();
            this.target = target;
            this.offset = position.cpy().sub(this$0.position);
            this.offset.x /= 16.0f;
            this.offset.y /= 16.0f;
            this.nextAction = nextAction;
        }

        @Override // com.corona.game.Action
        public void firstStep(Game game) {
            this.overSprite = Tile.this.overSprite;
            Tile.this.drawUpperBelowPlayer = false;
            Tile.this.overSprite = null;
            this.currPos = Tile.this.position.cpy();
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            this.currPos.add(this.offset);
            game.mapBatch.draw(this.overSprite, this.currPos.x, this.currPos.y);
            this.timer++;
            if (this.timer >= 16) {
                this.target.nameUpper = Tile.this.nameUpper;
                this.target.init();
                Tile.this.nameUpper = "";
                Tile.this.init();
                game.actionStack.remove(this);
                game.insertAction(this.nextAction);
            }
        }
    }

    /* JADX DEBUG: Multi-variable search result rejected for r0v858, resolved type: com.corona.game.Tile$1DrawMysteryNPC */
    /* JADX WARN: Multi-variable type inference failed */
    public void onPressA(Game game) {
        Action nextAction;
        String[] texts;
        Action emote;
        Action nextAction2;
        if (this.hasItem == null || isSign()) {
            if (game.map.pokemon.containsKey(this.position) && game.map.pokemon.get(this.position).mapTiles == game.map.tiles && !game.map.pokemon.get(this.position).aggroPlayer) {
                Pokemon pokemon = game.map.pokemon.get(this.position);
                if (game.type == Game.Type.CLIENT) {
                    game.client.sendTCP(new Network.PausePokemon(game.player.network.id, pokemon.position, true));
                    return;
                }
                Action nextAction3 = new Action(new Object[0]) { // from class: com.corona.game.Tile.1
                    @Override // com.corona.game.Action
                    public String getCamera() {
                        return "gui";
                    }
                };
                game.playerCanMove = false;
                if (!pokemon.specie.name.equals("darmanitanzen") || pokemon.previousOwner != null) {
                    pokemon.canMove = false;
                    String oppDir = "down";
                    if (game.player.dirFacing.equals("up")) {
                        oppDir = "down";
                    } else if (game.player.dirFacing.equals("down")) {
                        oppDir = "up";
                    } else if (game.player.dirFacing.equals("right")) {
                        oppDir = "left";
                    } else if (game.player.dirFacing.equals("left")) {
                        oppDir = "right";
                    }
                    boolean isBaseSpecies = true;
                    if (Pokemon.baseSpecies.get(pokemon.specie.name) != null) {
                        isBaseSpecies = Pokemon.baseSpecies.get(pokemon.specie.name).equals(pokemon.specie.name);
                    }
                    if (game.player.currFieldMove.equals("ATTACK")) {
                        if (isBaseSpecies && !pokemon.isEgg) {
                            pokemon.happiness = pokemon.specie.baseHappiness;
                        }
                        game.battle.oppPokemon = pokemon;
                        game.player.setCurrPokemon();
                        Objects.requireNonNull(pokemon);
                        game.insertAction(new SetField(pokemon, "dirFacing", oppDir, new WaitFrames(game, 20, new SplitAction(new Pokemon.Emote("!", null), new WaitFrames(game, 20, new PlayMusic(pokemon, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game))))))));
                    } else if (pokemon.previousOwner != game.player && !pokemon.isEgg && Pokemon.skittishMons.contains(pokemon.specie.name)) {
                        game.battle.oppPokemon = pokemon;
                        game.player.setCurrPokemon();
                        Objects.requireNonNull(pokemon);
                        game.insertAction(new SetField(pokemon, "dirFacing", oppDir, new WaitFrames(game, 20, new SplitAction(new Pokemon.Emote("!", null), new WaitFrames(game, 20, new PlayMusic(pokemon, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game))))))));
                    } else if (pokemon.previousOwner != game.player || pokemon.hasItem == null) {
                        boolean shouldAggro = Pokemon.aggroAnyway.contains(pokemon.specie.name) || (!isBaseSpecies && !Pokemon.dontAggro.contains(pokemon.specie.name));
                        if (pokemon.previousOwner == game.player || pokemon.isEgg || !shouldAggro) {
                            if (pokemon.isEgg) {
                                Objects.requireNonNull(pokemon);
                                emote = new Pokemon.Emote("...", null);
                            } else if (pokemon.previousOwner != game.player) {
                                Objects.requireNonNull(pokemon);
                                emote = new Pokemon.Emote("happy", null);
                            } else if (!pokemon.inHabitat) {
                                Objects.requireNonNull(pokemon);
                                emote = new Pokemon.Emote("uncomfortable", null);
                            } else if (pokemon.loveInterest != null) {
                                Objects.requireNonNull(pokemon);
                                emote = new Pokemon.Emote("heart", null);
                            } else {
                                Objects.requireNonNull(pokemon);
                                emote = new Pokemon.Emote("happy", null);
                            }
                            Action nextAction4 = new SetField(pokemon, "dirFacing", oppDir, new WaitFrames(game, 20, new SplitAction(emote, new WaitFrames(game, 20, new PlayMusic(pokemon, (Action) null)))));
                            if (pokemon.isEgg) {
                                String[] huhs = {"Neat!", "Hey!", "Look!", "Wow!", "Huh?", "Hmm..."};
                                nextAction4.append(new DisplayText(game, huhs[Game.rand.nextInt(huhs.length)] + " A POKéMON egg!", (String) null, false, true, (Action) null));
                            } else if (pokemon.previousOwner != game.player) {
                                nextAction4.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " seems friendly. ", (String) null, false, true, (Action) null));
                            } else if (pokemon.mapTiles != game.map.overworldTiles) {
                                nextAction4.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " is enjoying itself.", (String) null, false, true, (Action) null));
                            } else if (!pokemon.inHabitat) {
                                nextAction4.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " seems uncomfortable in this environment. ", (String) null, false, true, (Action) null));
                            } else if (pokemon.loveInterest != null) {
                                nextAction4.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " seems interested in " + pokemon.loveInterest.nickname.toUpperCase(Locale.ROOT) + ".", (String) null, false, true, (Action) null));
                            } else {
                                nextAction4.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " seems happy. ", (String) null, false, true, (Action) null));
                            }
                            nextAction4.append(new DisplayText(game, pokemon.isEgg ? "Pick it up?" : "Add " + pokemon.nickname.toUpperCase(Locale.ROOT) + " to your party?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 6, new RunCode(() -> {
                                Vector2 position = pokemon.position.cpy();
                                if (pokemon.standingAction instanceof Pokemon.Moving) {
                                    position = ((Pokemon.Moving) pokemon.standingAction).targetPos;
                                } else if (pokemon.standingAction instanceof Pokemon.Sliding) {
                                    position = ((Pokemon.Sliding) pokemon.standingAction).targetPos;
                                }
                                Objects.requireNonNull(pokemon);
                                Action action = new Pokemon.AddToInventory(position, null);
                                action.append(new RunCode(() -> {
                                    game.playerCanMove = true;
                                    pokemon.canMove = true;
                                }, null));
                                action.firstStep(game);
                            }, null))), new DisplayText.Clear(game, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, new SetField(pokemon, "canMove", true, null)))))));
                            game.insertAction(nextAction4);
                            return;
                        }
                        if (!pokemon.interactedWith) {
                            Objects.requireNonNull(pokemon);
                            nextAction2 = new SetField(pokemon, "dirFacing", oppDir, new WaitFrames(game, 20, new SplitAction(new Pokemon.Emote("skull", null), new WaitFrames(game, 20, new PlayMusic(pokemon, (Action) null)))));
                            nextAction2.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " seems aggressive... it may attack if provoked!", (String) null, false, true, (Action) null));
                            pokemon.interactedWith = true;
                            nextAction2.append(new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, new SetField(pokemon, "canMove", true, null))));
                        } else {
                            Objects.requireNonNull(pokemon);
                            nextAction2 = new SetField(pokemon, "dirFacing", oppDir, new WaitFrames(game, 20, new SplitAction(new Pokemon.Emote("!", null), new WaitFrames(game, 20, new PlayMusic(pokemon, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, new SetField(pokemon, "canMove", true, new SetField(pokemon, "aggroPlayer", true, null)))))))));
                        }
                        game.insertAction(nextAction2);
                    } else {
                        nextAction3.append(new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " looks like it' holding something...", (String) null, false, true, (Action) new DisplayText(game, pokemon.nickname.toUpperCase(Locale.ROOT) + " gave you " + pokemon.hasItem.toUpperCase(Locale.ROOT) + "!", "fanfare1.ogg", false, true, (Action) null)));
                        if (!game.player.alreadyDoneHarvestables.contains(pokemon.hasItem)) {
                            if (pokemon.hasItem.contains("manure")) {
                                nextAction3.append(new DisplayText(game, "It smells pretty bad... surely it will come in handy!", (String) null, false, true, (Action) null));
                            } else if (pokemon.hasItem.contains("wool")) {
                                nextAction3.append(new DisplayText(game, "Mmm... feels soft and warm.", (String) null, false, true, (Action) null));
                            } else if (pokemon.hasItem.contains("hard shell")) {
                                nextAction3.append(new DisplayText(game, "It' a piece of it' shell... feels nice and sturdy.", (String) null, false, true, (Action) null));
                            }
                            game.player.alreadyDoneHarvestables.add(pokemon.hasItem);
                        }
                        nextAction3.append(new SetField(pokemon, "harvestTimer", 0, new SetField(pokemon, "hasItem", null, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, new SetField(pokemon, "canMove", true, null))))));
                        int amount = 1;
                        if (game.player.hasItem(pokemon.hasItem)) {
                            amount = game.player.getItemAmount(pokemon.hasItem).intValue() + 1;
                        }
                        game.player.setItemAmount(pokemon.hasItem, amount);
                        game.insertAction(nextAction3);
                    }
                } else {
                    nextAction3.append(new DisplayText(game, "A statue of an ancient Pokemon.", (String) null, (Action) null, (Action) null));
                    if (game.player.hasItem("ragecandybar")) {
                        Player player = game.player;
                        Objects.requireNonNull(player);
                        nextAction3.append(new DisplayText(game, "Give it a RageCandyBar?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 6, new Player.RemoveFromInventory("ragecandybar", 1, new DisplayText(game, "The statue responded to the RageCandyBar...", (String) null, (Action) null, new DisplayText(game, "The awakened DARMANITAN attacked!", (String) null, (Action) null, new SetField(game.battle, "oppPokemon", pokemon, new CallMethod(game.player, "setCurrPokemon", new Object[0], new SetField(game.musicController, "startBattle", "wild", new Battle.GetIntroAction(null))))))))), new DisplayText.Clear(game, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, new SetField(pokemon, "canMove", true, null)))))));
                    } else {
                        nextAction3.append(new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null)));
                    }
                    game.insertAction(nextAction3);
                }
            } else if (game.player.hmPokemon != null && !game.player.hmPokemon.isEgg && game.player.currFieldMove.equals("") && game.player.hmPokemon.dirFacing.equals(Player.oppDirs.get(game.player.dirFacing))) {
                game.playerCanMove = false;
                Tile facingTile = game.map.tiles.get(game.player.facingPos());
                if (game.map.timeOfDay.equals("night")) {
                    if (game.player.hmPokemon.types.contains("PSYCHIC")) {
                        new String[1][0] = "POKEMON looks sleepy.";
                    } else if (game.player.hmPokemon.types.contains("DARK")) {
                        String[] strArr = {"POKEMON blends into the night.", "POKEMON is scouting for ghosts."};
                    } else if (game.player.hmPokemon.types.contains("FAIRY")) {
                        new String[1][0] = "POKEMON doesn't want me to go too far.";
                    }
                }
                if (facingTile.routeBelongsTo == null || !facingTile.routeBelongsTo.type().equals("desert")) {
                    if (facingTile.routeBelongsTo != null && facingTile.routeBelongsTo.name.contains("pkmnmansion")) {
                        texts = game.player.hmPokemon.types.contains("PSYCHIC") ? new String[]{"POKEMON picks up a signal.", "POKEMON pieces events together."} : new String[]{"POKEMON watches its step.", "POKEMON notices scattered papers.", "POKEMON nervously follows.", "POKEMON looks confused."};
                    } else if (facingTile.routeBelongsTo == null || !facingTile.routeBelongsTo.name.contains("snow")) {
                        if (facingTile.routeBelongsTo != null && facingTile.routeBelongsTo.name.contains("beach")) {
                            texts = game.player.hmPokemon.types.contains("WATER") ? new String[]{"POKEMON takes in the sea's aroma.", "POKEMON sticks to the waves."} : new String[]{"POKEMON notices the crashing waves.", "POKEMON plays in the sand.", "POKEMON spots shells in the sand.", "POKEMON shakes sand off."};
                        } else if (facingTile.routeBelongsTo == null || !facingTile.routeBelongsTo.name.contains("mountain")) {
                            if (facingTile.routeBelongsTo == null || !facingTile.routeBelongsTo.name.contains("forest")) {
                                if (game.player.hmPokemon.types.contains("FIGHTING")) {
                                    texts = new String[]{"POKEMON is stretching.", "POKEMON wants to spar."};
                                } else if (game.player.hmPokemon.types.contains("PSYCHIC")) {
                                    texts = new String[]{"POKEMON is thinking hard."};
                                } else if (game.player.hmPokemon.types.contains("DARK")) {
                                    texts = new String[]{"POKEMON is looking wary."};
                                } else {
                                    texts = game.player.hmPokemon.types.contains("FAIRY") ? new String[]{"POKEMON wants to play."} : new String[]{"POKEMON is carefully eyeing you.", "POKEMON is keeping at your pace.", "POKEMON is eager to help.", "POKEMON is surveying the area.", "POKEMON looks towards the sky.", "POKEMON notices you.", "POKEMON looks happy.", "POKEMON darts around.", "POKEMON passes the time.", "What? POKEMON hugs you!", "POKEMON shakes its head."};
                                }
                            } else if (game.player.hmPokemon.types.contains("GRASS")) {
                                texts = new String[]{"POKEMON admires the fresh plants.", "POKEMON reaches for a branch."};
                            } else if (game.player.hmPokemon.types.contains("BUG")) {
                                texts = new String[]{"POKEMON is chittering away.", "POKEMON is enjoying the flowers.", "POKEMON is on the lookout."};
                            } else {
                                texts = game.player.hmPokemon.types.contains("FLYING") ? new String[]{"POKEMON is on the lookout."} : new String[]{"POKEMON stares into the treetops.", "POKEMON takes in the natural scent.", "POKEMON makes its way across the path."};
                            }
                        } else if (game.player.hmPokemon.types.contains("ROCK") || game.player.hmPokemon.types.contains("GROUND")) {
                            texts = new String[]{"POKEMON is impressed by the landscape.", "Wow! POKEMON blends in with the environment!"};
                        } else if (game.player.hmPokemon.types.contains("FIGHTING")) {
                            texts = new String[]{"POKEMON wants to mountain climb."};
                        } else {
                            texts = game.player.hmPokemon.types.contains("FLYING") ? new String[]{"POKEMON is enjoying the breeze.", "POKEMON wants to soar the skies."} : new String[]{"POKEMON enjoys the view.", "POKEMON spots pretty rocks.", "POKEMON watches by the cliffside."};
                        }
                    } else if (game.player.hmPokemon.types.contains("ICE")) {
                        texts = new String[]{"POKEMON feels comfortable under the snow.", "POKEMON takes in the cold environment."};
                    } else if (game.player.hmPokemon.types.contains("GRASS") || game.player.hmPokemon.types.contains("GROUND")) {
                        texts = new String[]{"POKEMON shutters from the air.", "POKEMON does not take a liking to the weather."};
                    } else if (game.player.hmPokemon.types.contains("DRAGON")) {
                        texts = new String[]{"POKEMON is shivering."};
                    } else {
                        texts = game.player.hmPokemon.types.contains("PSYCHIC") ? new String[]{"POKEMON has a brain freeze."} : new String[]{"POKEMON notices the frigid air.", "POKEMON stares into ice crystals.", "POKEMON collects snow.", "POKEMON feels the powdery snow."};
                    }
                } else if (game.player.hmPokemon.types.contains("ICE")) {
                    texts = new String[]{"POKEMON keeps away from the sunlight.", "POKEMON dislikes the heat."};
                } else if (game.player.hmPokemon.types.contains("DRAGON")) {
                    texts = new String[]{"POKEMON is soaking up the sun."};
                } else if (game.player.hmPokemon.types.contains("DRAGON")) {
                    texts = new String[]{"[Steel Type] is hot to the touch."};
                } else if (game.player.hmPokemon.types.contains("GROUND")) {
                    texts = new String[]{"POKEMON is submerged in sand.", "POKEMON is moving easily in the sand."};
                } else {
                    texts = game.player.hmPokemon.types.contains("FIRE") ? new String[]{"POKEMON loves the hot sun.", "POKEMON is having trouble with the sand."} : new String[]{"POKEMON feels sunlight on its back.", "POKEMON digs into the sand.", "POKEMON makes its way across the sand.", "POKEMON shakes sand off."};
                }
                game.insertAction(new DisplayText(game, texts[Game.rand.nextInt(texts.length)].replace("POKEMON", game.player.hmPokemon.nickname.toUpperCase(Locale.ROOT)), (String) null, (Action) null, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))));
            } else if (this.nameUpper.equals("odd_keystone2")) {
                game.playerCanMove = false;
                int amountLeft = 107 - this.hasItemAmount;
                String text = "A voice whispers from within... " + String.valueOf(amountLeft) + "... bring " + String.valueOf(amountLeft) + "...";
                if (amountLeft == 69) {
                    text = "A voice whispers from within... bring 69... Nice...";
                }
                Action nextAction5 = new DisplayText(game, text, (String) null, (Action) null, (Action) null);
                if (game.player.hasItem("life force")) {
                    Player.Craft craft = new Player.Craft("life force", 1);
                    craft.requirements.add(new Player.Craft("life force", 1));
                    nextAction5.append(new DisplayText(game, "Use life force?", (String) null, true, false, (Action) new SelectAmount(craft, new DisplayText.Clear(game, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))), new DisplayText.Clear(game, new WaitFrames(game, 6, new Action(craft, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))) { // from class: com.corona.game.Tile.1ChoiceAction
                        Player.Craft craft;

                        {
                            this.craft = craft;
                            this.nextAction = nextAction;
                        }

                        @Override // com.corona.game.Action
                        public void step(Game game2) {
                            Tile.this.hasItemAmount += this.craft.amount;
                            if (Tile.this.hasItemAmount > 107) {
                                this.craft.amount -= Tile.this.hasItemAmount - 107;
                            }
                            if (Tile.this.hasItemAmount >= 107) {
                                this.nextAction = new WaitFrames(game2, 20, new SetField(Tile.this, "nameUpper", "spiritomb", new CallMethod(Tile.this, "init", new Object[0], new PokemonFrame(new Pokemon("spiritomb", 2, Pokemon.Generation.CRYSTAL, false, false), this.nextAction))));
                            }
                            if (this.craft.amount == 69) {
                                this.nextAction = new DisplayText(game2, "69... Nice...", (String) null, (Action) null, this.nextAction);
                            }
                            game2.actionStack.remove(this);
                            Player player2 = game2.player;
                            Objects.requireNonNull(player2);
                            game2.insertAction(new Player.RemoveFromInventory(this.craft.name, this.craft.amount, new DisplayText(game2, "The spirits entered into the keystone...", "attacks/hypnosis_player_gsc/sound.ogg", (Action) null, this.nextAction)));
                        }
                    })))));
                } else {
                    nextAction5.append(new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null)));
                }
                game.insertAction(nextAction5);
            } else if (this.nameUpper.contains("warp_tile")) {
                game.playerCanMove = false;
                game.insertAction(new DisplayText(game, "Set label text?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 3, new SetSignText(this.hasItem, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))))), new DisplayText.Clear(game, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))))));
            } else if (isSign() && game.player.dirFacing.equals("up")) {
                game.playerCanMove = false;
                if (this.hasItem == null) {
                    game.insertAction(new SetSignText(null, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))));
                } else {
                    game.insertAction(new DisplayText(game, this.hasItem, (String) null, (Action) null, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null))));
                }
            } else if (this.nameUpper.equals("gravestone2") && game.player.dirFacing.equals("up")) {
                game.playerCanMove = false;
                Action nextAction6 = new DisplayText(game, "The text is too faded to make out...", (String) null, (Action) null, new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null)));
                Tile down = game.map.tiles.get(this.position.cpy().add(0.0f, -32.0f));
                Tile right = game.map.tiles.get(this.position.cpy().add(16.0f, -16.0f));
                if (Game.rand.nextInt(128) == 0 && ((down != null && !down.isSolid) || (right != null && !right.isSolid))) {
                    game.playerCanMove = true;
                    game.player.acceptInput = false;
                    AnonymousClass1DrawMysteryNPC drawMysteryNPC = new Action(null) { // from class: com.corona.game.Tile.1DrawMysteryNPC
                        Vector2 position;
                        public boolean stop = false;
                        Texture texture = TextureCache.get(Gdx.files.internal("npc1.png"));

                        {
                            this.nextAction = nextAction;
                        }

                        @Override // com.corona.game.Action
                        public String getCamera() {
                            return "map";
                        }

                        @Override // com.corona.game.Action
                        public Layer getLayer() {
                            return Layer.map_114;
                        }

                        @Override // com.corona.game.Action
                        public void firstStep(Game game2) {
                            game2.insertAction(this.nextAction);
                            Vector3 worldCoords = game2.cam.unproject(new Vector3(0.0f, 0.0f, 0.0f));
                            this.position = new Vector2(worldCoords.x, worldCoords.y - 16.0f);
                        }

                        @Override // com.corona.game.Action
                        public void step(Game game2) {
                            game2.mapBatch.draw(this.texture, this.position.x, this.position.y + 1.0f);
                            if (this.stop) {
                                game2.actionStack.remove(this);
                            }
                        }
                    };
                    drawMysteryNPC.append(new DisplayText(game, "The text is too faded to make out...", (String) null, (Action) null, (Action) null));
                    if (down == null || down.isSolid) {
                        drawMysteryNPC.append(new SetField(game.player, "dirFacing", "right", new SetField(game.player, "currSprite", game.player.standingSprites.get("right"), null)));
                    } else {
                        drawMysteryNPC.append(new SetField(game.player, "dirFacing", "down", new SetField(game.player, "currSprite", game.player.standingSprites.get("down"), null)));
                    }
                    drawMysteryNPC.append(new PlayerMoving(game, game.player, false, new WaitFrames(game, 10, new SetField(game.player, "acceptInput", true, new SetField(drawMysteryNPC, "stop", true, null)))));
                    nextAction6 = drawMysteryNPC;
                }
                game.insertAction(nextAction6);
            } else if (this.name.equals("cave1_regi5")) {
                Tile leftTile = game.map.tiles.get(this.position.cpy().add(-16.0f, 0.0f));
                if (leftTile != null) {
                    leftTile.onPressA(game);
                }
            } else if (this.name.equals("cave1_regi2")) {
                game.playerCanMove = false;
                game.insertAction(new DisplayText(game, "...", (String) null, false, true, (Action) new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))));
            } else if (this.name.equals("cave1_regi3")) {
                MoveWater.regiTimer2 = 0;
                game.playerCanMove = false;
                game.battle.oppPokemon = new Pokemon("regigigas", 70);
                game.battle.oppPokemon.position = this.position.cpy();
                game.player.setCurrPokemon();
                game.insertAction(RegigigasBattle.getIntroAction(game));
            } else if (this.nameUpper.contains("REGI")) {
                Pokemon regi = new Pokemon(this.nameUpper.toLowerCase(Locale.ROOT), 40);
                game.playerCanMove = false;
                game.battle.oppPokemon = regi;
                game.player.setCurrPokemon();
                String cryText = "";
                if (this.nameUpper.equals("REGIELEKI")) {
                    cryText = "Zizi zizizi.";
                } else if (this.nameUpper.equals("REGIDRAGO")) {
                    cryText = "Zagd.";
                } else if (this.nameUpper.equals("REGISTEEL")) {
                    cryText = "Ji-ji-ze-ji-zoh.";
                } else if (this.nameUpper.equals("REGIROCK")) {
                    cryText = "Zaza zari za...";
                } else if (this.nameUpper.equals("REGICE")) {
                    cryText = "Jakiih!";
                }
                game.insertAction(new DisplayText(game, cryText, "pokemon/cries/" + regi.dexNumber + ".ogg", (Action) null, new SetField(game.musicController, "startBattle", "regi_battle1", new SplitAction(new CallMethod(game.uiBatch, "setColor", new Object[]{new Color(1.0f, 1.0f, 1.0f, 1.0f)}, null), new CallMethod(game.mapBatch, "setColor", new Object[]{new Color(0.5f, 0.5f, 0.5f, 1.0f)}, new SplitAction(new RegigigasIntroAnim.BattleIntro(null), new WaitFrames(game, 230, Battle.getIntroAction(game))))))));
            } else if (this.name.equals("cave1_regipedistal1")) {
                game.playerCanMove = false;
                game.player.isCrafting = true;
                game.player.regiCrafts.clear();
                if (items().containsKey("REGISTEEL")) {
                    Player.Craft craft2 = new Player.Craft("REGISTEEL", 1);
                    craft2.requirements.add(new Player.Craft("metal coat", 47));
                    craft2.requirements.add(new Player.Craft("spell tag", 1));
                    game.player.regiCrafts.add(craft2);
                }
                if (items().containsKey("REGIROCK")) {
                    Player.Craft craft3 = new Player.Craft("REGIROCK", 1);
                    craft3.requirements.add(new Player.Craft("hard stone", 47));
                    craft3.requirements.add(new Player.Craft("spell tag", 1));
                    game.player.regiCrafts.add(craft3);
                }
                if (items().containsKey("REGICE")) {
                    Player.Craft craft4 = new Player.Craft("REGICE", 1);
                    craft4.requirements.add(new Player.Craft("nevermeltice", 47));
                    craft4.requirements.add(new Player.Craft("spell tag", 1));
                    game.player.regiCrafts.add(craft4);
                }
                if (items().containsKey("REGIDRAGO")) {
                    Player.Craft craft5 = new Player.Craft("REGIDRAGO", 1);
                    craft5.requirements.add(new Player.Craft("dragon scale", 43));
                    craft5.requirements.add(new Player.Craft("dragon fang", 4));
                    craft5.requirements.add(new Player.Craft("spell tag", 1));
                    game.player.regiCrafts.add(craft5);
                }
                if (items().containsKey("REGIELEKI")) {
                    Player.Craft craft6 = new Player.Craft("REGIELEKI", 1);
                    craft6.requirements.add(new Player.Craft("magnet", 43));
                    craft6.requirements.add(new Player.Craft("binding band", 4));
                    craft6.requirements.add(new Player.Craft("spell tag", 1));
                    game.player.regiCrafts.add(craft6);
                }
                game.insertAction(new DrawCraftsMenu.Intro(null, 9, new DrawCraftsMenu(game, game.player.regiCrafts, new SetField(game, "playerCanMove", true, new SetField(game.player, "isCrafting", false, null)))));
            } else if (this.nameUpper.equals("ball_kiln1")) {
                game.playerCanMove = false;
                game.player.isCrafting = true;
                game.insertAction(new DrawCraftsMenu.Intro(null, 9, new DrawCraftsMenu(game, Player.kilnCrafts, new SetField(game, "playerCanMove", true, new SetField(game.player, "isCrafting", false, null)))));
            } else if (this.name.equals("building1_pokecenter1_right")) {
                Tile leftTile2 = game.map.tiles.get(this.position.cpy().add(-16.0f, 0.0f));
                if (leftTile2 != null) {
                    leftTile2.onPressA(game);
                }
            } else if (this.name.equals("building1_fossilreviver1") && game.player.dirFacing.equals("up")) {
                game.playerCanMove = false;
                boolean foundRevivedMon = false;
                Iterator<Tile> it = game.map.tiles.values().iterator();
                while (true) {
                    if (it.hasNext()) {
                        if (it.next().nameUpper.contains("revived")) {
                            foundRevivedMon = true;
                            break;
                        }
                    } else {
                        break;
                    }
                }
                if (foundRevivedMon) {
                    game.insertAction(new DisplayText(game, "It' not responding...", (String) null, false, true, (Action) new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))));
                } else if (game.player.hmPokemon == null || !game.player.currFieldMove.equals("POWER")) {
                    game.insertAction(new DisplayText(game, "No power... an ELECTRIC type could get it running.", (String) null, false, true, (Action) new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))));
                } else {
                    game.player.isCrafting = true;
                    game.insertAction(new FossilMachinePowerUp(false, new PlayMusic("pc_on1", new DisplayText(game, game.player.hmPokemon.nickname.toUpperCase(Locale.ROOT) + " powered up the machine!", (String) null, false, true, (Action) new DrawCraftsMenu.Intro(null, 9, new DrawCraftsMenu(game, game.player.fossilCrafts, new FossilMachinePowerUp(true, new PlayMusic("pc_off1", new SetField(game, "playerCanMove", true, new SetField(game.player, "isCrafting", false, null))))))))));
                }
            } else if (this.nameUpper.contains("revived_")) {
                game.playerCanMove = false;
                int averageLevel = 0;
                int numberPokemon = 0;
                Iterator<Pokemon> it2 = game.player.pokemon.iterator();
                while (it2.hasNext()) {
                    Pokemon mon = it2.next();
                    if (!mon.isEgg) {
                        averageLevel += mon.level;
                        numberPokemon++;
                    }
                }
                if (numberPokemon <= 0) {
                    System.out.println("WARNING: this should never happen. Might want to look into it.");
                    numberPokemon = 1;
                }
                int averageLevel2 = ((averageLevel / numberPokemon) - 3) + Game.rand.nextInt(3);
                if (averageLevel2 > 50) {
                    averageLevel2 = 50;
                }
                Pokemon pokemon2 = new Pokemon(this.nameUpper.split("_")[1].toLowerCase(Locale.ROOT), averageLevel2, Pokemon.Generation.CRYSTAL);
                if (!game.player.currFieldMove.equals("CHARM") || game.player.hmPokemon == null) {
                    game.playerCanMove = false;
                    game.battle.oppPokemon = pokemon2;
                    pokemon2.onTile = this;
                    game.player.setCurrPokemon();
                    game.insertAction(new DisplayText(game, pokemon2.nickname.toUpperCase(Locale.ROOT) + " attacked!", "pokemon/cries/" + pokemon2.dexNumber + ".ogg", (Action) null, new WaitFrames(game, 10, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game)))));
                } else if (game.player.pokemon.size() >= 6) {
                    game.insertAction(new DisplayText.Clear(game, new WaitFrames(game, 3, new PlayMusic("error1", new DisplayText(game, "Not enough room in your party!", (String) null, (Action) null, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null)))))));
                } else {
                    Action newAction = new DisplayText(game, game.player.name + " received " + pokemon2.nickname.toUpperCase(Locale.ROOT) + "!", "fanfare1.ogg", (Action) null, new SetField(game, "playerCanMove", true, null));
                    this.nameUpper = "";
                    game.player.pokemon.add(pokemon2);
                    pokemon2.previousOwner = game.player;
                    game.insertAction(newAction);
                }
            } else if (this.nameUpper.equals("volcarona")) {
                Pokemon pokemon3 = new Pokemon(this.nameUpper, 60, Pokemon.Generation.CRYSTAL);
                game.playerCanMove = false;
                game.battle.oppPokemon = pokemon3;
                pokemon3.onTile = this;
                game.player.setCurrPokemon();
                game.insertAction(new DisplayText(game, "Vraahhbrbrbr!", "pokemon/cries/" + pokemon3.dexNumber + ".ogg", (Action) null, new WaitFrames(game, 10, new SetField(game.musicController, "startBattle", "bw_legendary_theme3", new WaitFrames(game, 80, Battle.getIntroAction(game))))));
            } else if (this.nameUpper.equals("spiritomb")) {
                Pokemon pokemon4 = new Pokemon(this.nameUpper, 25, Pokemon.Generation.CRYSTAL);
                game.playerCanMove = false;
                game.battle.oppPokemon = pokemon4;
                pokemon4.onTile = this;
                game.player.setCurrPokemon();
                game.insertAction(new DisplayText(game, "Yulaaah!", "pokemon/cries/" + pokemon4.dexNumber + ".ogg", (Action) null, new WaitFrames(game, 10, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game)))));
            } else if (this.nameUpper.equals("pokedoll1")) {
                game.playerCanMove = false;
                game.insertAction(new SplitAction(new WaitFrames(game, 15, new SetField(this, "nameUpper", "", new SetField(this, "overSprite", null, new CallMethod(this, "init", new Object[0], null)))), new DisplayText(game, "Found a " + "poké doll".toUpperCase(Locale.ROOT) + "!", "fanfare1.ogg", (Action) null, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null)))));
                int amount2 = 1;
                if (game.player.hasItem("poké doll")) {
                    amount2 = 1 + game.player.getItemAmount("poké doll").intValue();
                }
                game.player.setItemAmount("poké doll", amount2);
            } else if (this.nameUpper.equals("pokedoll1_banette") || this.nameUpper.equals("pokedoll1_mimikyu")) {
                String name = "banette";
                if (this.nameUpper.equals("pokedoll1_mimikyu")) {
                    name = "mimikyu";
                }
                game.playerCanMove = false;
                game.battle.oppPokemon = new Pokemon(name, 24, Pokemon.Generation.CRYSTAL);
                game.battle.oppPokemon.mapTiles = game.map.overworldTiles;
                game.battle.oppPokemon.position = this.position.cpy();
                game.battle.oppPokemon.canMove = false;
                game.battle.oppPokemon.aggroPlayer = true;
                game.player.setCurrPokemon();
                PlayMusic playMusic = new PlayMusic("ledge2", (Action) null);
                Player player2 = game.player;
                Objects.requireNonNull(player2);
                Pokemon pokemon5 = game.battle.oppPokemon;
                Objects.requireNonNull(pokemon5);
                game.insertAction(new SplitAction(playMusic, new Player.Emote("!", new DisplayText(game, "The doll became animated... and attacked!", (String) null, (Action) null, new SplitAction(new WaitFrames(game, 400, new SetField(this, "nameUpper", "", new SetField(this, "overSprite", null, new CallMethod(this, "init", new Object[0], new Pokemon.Standing())))), new WaitFrames(game, 10, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game))))))));
            } else if (this.nameUpper.contains("house_wardrobe")) {
                game.playerCanMove = false;
                if (!game.player.currFieldMove.equals("")) {
                    game.insertAction(new PlayMusic("error1", new DisplayText(game, "Canì use this while using a Field Move.", (String) null, (Action) null, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null)))));
                } else {
                    game.insertAction(new DisplayText(game, "Arrow left or right to change clothes color.", (String) null, true, true, (Action) new ChangePlayerColor(new DisplayText.Clear(game, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))))));
                }
            } else if (this.nameUpper.contains("house_vanity")) {
                game.playerCanMove = false;
                if (!game.player.currFieldMove.equals("")) {
                    game.insertAction(new PlayMusic("error1", new DisplayText(game, "Canì use this while using a Field Move.", (String) null, (Action) null, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null)))));
                } else {
                    game.insertAction(new DisplayText(game, "Arrow left or right to change appearance.", (String) null, true, true, (Action) new ChangePlayerCharacter(new DisplayText.Clear(game, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))))));
                }
            } else if (this.name.contains("pkmnmansion_ext_locked") || this.nameUpper.contains("pkmnmansion_ext_locked")) {
                game.playerCanMove = false;
                if (!game.player.hasItem("secret key")) {
                    nextAction = new DisplayText(game, "It' locked...", (String) null, false, true, (Action) new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null)));
                } else {
                    Player player3 = game.player;
                    Objects.requireNonNull(player3);
                    nextAction = new DisplayText(game, "It' locked...", (String) null, false, true, (Action) new DisplayText(game, "Open using the SECRET KEY?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 3, new Player.RemoveFromInventory("secret key", 1, new PutTile(new Tile("pkmnmansion_ext_door", this.position.cpy(), true, this.routeBelongsTo), this.position.cpy(), new DisplayText(game, "The door opened!", "fanfare1.ogg", (Action) null, new SetField(game, "playerCanMove", true, null)))))), new DisplayText.Clear(game, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))))));
                }
                game.insertAction(nextAction);
            } else if (this.name.equals("pkmnmansion_statue1") && this.doorTiles != null && game.player.dirFacing.equals("up")) {
                game.playerCanMove = false;
                ArrayList<Tile> flipDoors = new ArrayList<>();
                Iterator<Vector2> it3 = this.doorTiles.iterator();
                while (it3.hasNext()) {
                    flipDoors.add(game.map.interiorTiles.get(game.map.interiorTilesIndex - 1).get(it3.next()));
                }
                game.insertAction(new DisplayText(game, "A hidden switch! Press it?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 20, new PlayMusic("enter1", new FlipDoorTile(flipDoors, new SetField(game, "playerCanMove", true, null))))), new DisplayText.Clear(game, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))))));
            } else if (this.nameUpper.contains("bed")) {
                Vector2 newSpawnLoc = game.player.position.cpy();
                game.playerCanMove = false;
                Vector2 newPos = this.position.cpy();
                game.insertAction(new DisplayText(game, "Do you want to sleep?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 20, new RunCode(() -> {
                    game.player.sleepingDir = newPos;
                    game.player.isSleeping = true;
                    game.playerCanMove = true;
                    game.player.spawnLoc = newSpawnLoc;
                    game.player.spawnIndex = -1;
                    if (game.map.tiles != game.map.overworldTiles) {
                        game.player.spawnIndex = game.map.interiorTilesIndex;
                    }
                }, null))), new DisplayText.Clear(game, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))))));
            } else if (this.nameUpper.contains("onpress_above")) {
                Tile down2 = game.map.tiles.get(this.position.cpy().add(0.0f, -16.0f));
                String name2 = this.name;
                String nameUpper = this.nameUpper;
                Vector2 position = this.position;
                this.name = down2.name;
                this.nameUpper = down2.nameUpper;
                this.position = down2.position;
                onPressA(game);
                this.name = name2;
                this.nameUpper = nameUpper;
                this.position = position;
            } else if (this.nameUpper.contains("onpress_left")) {
                Tile left = game.map.tiles.get(this.position.cpy().add(-16.0f, 0.0f));
                String name3 = this.name;
                String nameUpper2 = this.nameUpper;
                this.name = left.name;
                this.nameUpper = left.nameUpper;
                onPressA(game);
                this.name = name3;
                this.nameUpper = nameUpper2;
            } else if (this.nameUpper.contains("house_couch")) {
                game.playerCanMove = false;
                Player player4 = game.player;
                Objects.requireNonNull(player4);
                game.insertAction(new WaitFrames(game, 30, new Player.Sitting(this)));
            } else if (this.nameUpper.equals("house_window1")) {
                game.insertAction(new PlayMusic("seed1", (Action) null));
                if (this.overSprite.getRegionX() == 0) {
                    this.overSprite.setRegion(16, 0, 16, 16);
                } else if (this.overSprite.getRegionX() == 16) {
                    this.overSprite.setRegion(32, 0, 16, 16);
                } else {
                    this.overSprite.setRegion(0, 0, 16, 16);
                }
            } else if (this.nameUpper.equals("house_window2")) {
                game.insertAction(new PlayMusic("seed1", (Action) null));
                if (this.overSprite.getRegionX() == 0) {
                    this.overSprite.setRegion(16, 0, 16, 16);
                } else {
                    this.overSprite.setRegion(0, 0, 16, 16);
                }
            } else if (this.nameUpper.contains("_plush")) {
                String name4 = "";
                String[] names = this.nameUpper.split("_plush");
                if (names.length > 1) {
                    name4 = names[1];
                }
                game.playerCanMove = false;
                game.insertAction(new DisplayText(game, "A " + name4.toUpperCase(Locale.ROOT) + " doll. Cute!", (String) null, (Action) null, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))));
            } else if (this.nameUpper.equals("mewtwo_overworld")) {
                game.playerCanMove = false;
                SpecialMewtwo1 mewtwo = new SpecialMewtwo1(50, this);
                game.battle.oppPokemon = mewtwo;
                game.player.setCurrPokemon();
                game.musicController.inBattle = true;
                game.insertAction(new SplitAction(new FadeMusic(game.currMusic, -0.025f, null), new WaitFrames(game, 20, new DisplayText(game, "...", (String) null, false, true, (Action) new WaitFrames(game, 100, new SpecialBattleMewtwo(game, mewtwo))))));
            } else if (items().containsKey("torch")) {
                game.playerCanMove = false;
                game.insertAction(new DisplayText(game, "Remove torch?", (String) null, true, false, (Action) new DrawYesNoMenu(null, new DisplayText.Clear(game, new WaitFrames(game, 3, new PickupItem(items(), "torch", new SetField(this, "isTorch", false, new SetField(game, "playerCanMove", true, null))))), new DisplayText.Clear(game, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))))));
            } else if (this.nameUpper.contains("rock1_color")) {
                game.playerCanMove = false;
                game.insertAction(new DisplayText(game, "A Rock-type POKéMON can break this using ROCK SMASH.", (String) null, (Action) null, new WaitFrames(game, 3, new SetField(game, "playerCanMove", true, null))));
            } else if ((this.name.contains("water") || this.name.equals("desert2")) && game.player.currFieldMove.equals("") && game.player.currRod.contains("rod")) {
                String rodName = game.player.currRod;
                game.playerCanMove = false;
                String dirFacing = game.player.dirFacing;
                Sprite fishingSprite = new Sprite(game.player.fishingSprites);
                if (dirFacing.equals("up")) {
                    fishingSprite.setRegion(0, 0, 16, 24);
                } else if (dirFacing.equals("down")) {
                    fishingSprite.setRegion(16, 0, 16, 24);
                } else if (dirFacing.equals("left")) {
                    fishingSprite.setRegion(32, 0, 24, 16);
                    fishingSprite.flip(true, false);
                } else if (dirFacing.equals("right")) {
                    fishingSprite.setRegion(32, 0, 24, 16);
                }
                Action nextAction7 = new PlayMusic("rod1", new SplitAction(new SetField(game.player, "isFishing", true, null), new SetField(game.player, "currSprite", fishingSprite, null)));
                if (Game.rand.nextInt(2) == 0) {
                    Route route = new Route("", 2);
                    if (this.routeBelongsTo != null && this.routeBelongsTo.name.equals("oasis1")) {
                        route.name = "oasis_pond1";
                    } else if (this.routeBelongsTo != null && this.routeBelongsTo.name.equals("wooded_lake_water1")) {
                        route.name = "wooded_lake_fishing1";
                    } else if (this.name.equals("water2")) {
                        route.name = "sea1";
                    } else if (this.name.equals("desert2")) {
                        route.name = "sand_fishing1";
                    } else {
                        route.name = "river1";
                    }
                    ArrayList<String> eligiblePokemon = new ArrayList<>(route.allowedPokemon());
                    Iterator<String> it4 = eligiblePokemon.iterator();
                    while (it4.hasNext()) {
                        System.out.println(it4.next());
                    }
                    if (rodName.equals("old rod") || rodName.equals("good rod")) {
                        Iterator<String> it5 = route.superRodPokemon().iterator();
                        while (it5.hasNext()) {
                            eligiblePokemon.remove(it5.next());
                        }
                    }
                    if (rodName.equals("old rod")) {
                        Iterator<String> it6 = route.goodRodPokemon().iterator();
                        while (it6.hasNext()) {
                            eligiblePokemon.remove(it6.next());
                        }
                    }
                    Iterator<String> it7 = eligiblePokemon.iterator();
                    while (it7.hasNext()) {
                        System.out.println(it7.next());
                    }
                    String name5 = eligiblePokemon.get(Game.rand.nextInt(eligiblePokemon.size()));
                    int level = 10;
                    if (rodName.equals("good rod")) {
                        level = 20;
                    } else if (rodName.equals("super rod")) {
                        level = 30;
                    }
                    Pokemon pokemon6 = new Pokemon(name5, level, Pokemon.Generation.CRYSTAL);
                    String evolveTo = null;
                    boolean failed = false;
                    while (!failed) {
                        failed = true;
                        Map<String, String> evos = Specie.gen2Evos.get(pokemon6.specie.name);
                        Iterator<String> it8 = evos.keySet().iterator();
                        while (true) {
                            if (it8.hasNext()) {
                                String evo = it8.next();
                                try {
                                    if (Integer.valueOf(evo).intValue() <= pokemon6.level && Game.rand.nextInt(256) >= 128) {
                                        evolveTo = evos.get(evo);
                                        pokemon6.evolveTo(evolveTo);
                                        failed = false;
                                        break;
                                    }
                                } catch (NumberFormatException e) {
                                    if (Game.rand.nextInt(256) >= 192) {
                                        evolveTo = evos.get(evo);
                                        pokemon6.evolveTo(evolveTo);
                                        failed = false;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    if (evolveTo != null) {
                        pokemon6.getCurrentAttacks();
                    }
                    String[] huhs2 = {"Whoa!             ", "Oh!               ", "Huh?              ", "What!?            "};
                    String huh = huhs2[Game.rand.nextInt(huhs2.length)];
                    game.player.setCurrPokemon();
                    game.battle.oppPokemon = pokemon6;
                    Player player5 = game.player;
                    Objects.requireNonNull(player5);
                    Player player6 = game.player;
                    Objects.requireNonNull(player6);
                    nextAction7.append(new WaitFrames(game, 120, new Player.CaughtFishAnim(new Player.Emote("!", new DisplayText(game, huh + "A bite!", (String) null, (Action) null, new WaitFrames(game, 30, new SplitAction(new SetField(game.player, "isFishing", false, null), new SetField(game.player, "currSprite", game.player.standingSprites.get(dirFacing), new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game, true))))))))));
                } else {
                    String[] huhs3 = {"!", "..."};
                    nextAction7.append(new WaitFrames(game, 120, new DisplayText(game, "Not even a nibble" + huhs3[Game.rand.nextInt(huhs3.length)], (String) null, (Action) null, new SplitAction(new SetField(game.player, "isFishing", false, null), new SetField(game, "playerCanMove", true, new WaitFrames(game, 30, null))))));
                }
                game.insertAction(nextAction7);
            } else if (this.isWater) {
                Pokemon surfMon = null;
                Iterator<Pokemon> it9 = game.player.pokemon.iterator();
                while (true) {
                    if (!it9.hasNext()) {
                        break;
                    }
                    Pokemon pokemon7 = it9.next();
                    if (pokemon7.hms.contains("SURF")) {
                        surfMon = pokemon7;
                        break;
                    }
                }
                Pokemon facingPokemon = game.map.pokemon.get(game.player.facingPos());
                boolean pokemonInTheWay = facingPokemon != null && facingPokemon.mapTiles == game.map.tiles;
                if (surfMon != null && !game.player.currFieldMove.equals("SURF") && !pokemonInTheWay) {
                    Action yesAction = new DisplayText.Clear(game, new WaitFrames(game, 3, new PlayMusic(surfMon, new DisplayText(game, surfMon.nickname.toUpperCase(Locale.ROOT) + " is using SURF!", (String) null, (Action) null, (Action) null))));
                    if (game.player.hmPokemon != null) {
                        if (!game.player.currFieldMove.equals("")) {
                            yesAction.append(new RunCode(() -> {
                                game.player.swapSprites(game.player.hmPokemon);
                                game.player.currPlanting = null;
                            }, null));
                        }
                        yesAction.append(new RunCode(() -> {
                            game.player.hmPokemon.removeDrawActions(game);
                        }, null));
                    }
                    yesAction.append(new RunCode(() -> {
                        game.player.swapSpritesSurfing(surfMon);
                        game.player.currFieldMove = "SURF";
                    }, new PlayerMoving(game, game.player, false, new RunCode(() -> {
                        game.player.acceptInput = true;
                    }, null))));
                    game.player.acceptInput = false;
                    game.insertAction(new DisplayText(game, "Want to SURF?", (String) null, true, false, (Action) new DrawYesNoMenu(null, yesAction, new DisplayText.Clear(game, new WaitFrames(game, 10, new SetField(game.player, "acceptInput", true, null))))));
                }
            } else if (this.nameUpper.contains("berrytree_")) {
                if (this.routeBelongsTo != null && !this.routeBelongsTo.storedPokemon.isEmpty()) {
                    game.playerCanMove = false;
                    game.battle.oppPokemon = this.routeBelongsTo.storedPokemon.remove(0);
                    game.battle.oppPokemon.mapTiles = game.map.overworldTiles;
                    game.battle.oppPokemon.position = this.position.cpy();
                    game.battle.oppPokemon.canMove = false;
                    game.player.setCurrPokemon();
                    PlayMusic playMusic2 = new PlayMusic("ledge2", (Action) null);
                    Player player7 = game.player;
                    Objects.requireNonNull(player7);
                    Pokemon pokemon8 = game.battle.oppPokemon;
                    Objects.requireNonNull(pokemon8);
                    game.insertAction(new SplitAction(playMusic2, new Player.Emote("!", new DisplayText(game, "The tree became agitated and attacked!", (String) null, (Action) null, new SplitAction(new WaitFrames(game, 400, new SetField(this, "nameUpper", "", new SetField(this, "overSprite", null, new CallMethod(this, "init", new Object[0], new Pokemon.Standing())))), new WaitFrames(game, 10, new SetField(game.musicController, "startBattle", "wild", Battle.getIntroAction(game))))))));
                } else if (this.nameUpper.contains("_full")) {
                    game.playerCanMove = false;
                    String berryType = this.nameUpper.split("_")[1];
                    String an = "a";
                    if (berryType.equals("aspear")) {
                        an = an + "n";
                    }
                    String str = "Look! A" + berryType.toUpperCase(Locale.ROOT) + " berry!";
                    String berryType2 = berryType + " berry";
                    Action nextAction8 = new DisplayText(game, game.player.name.toUpperCase(Locale.ROOT) + " got " + an + " " + berryType2.toUpperCase(Locale.ROOT) + "!", "Berry_Get.ogg", false, true, (Action) new WaitFrames(game, 10, new SetField(game, "playerCanMove", true, null)));
                    int amount3 = 1;
                    System.out.println(berryType2);
                    if (game.player.hasItem(berryType2)) {
                        amount3 = game.player.getItemAmount(berryType2).intValue() + 1;
                    }
                    game.player.setItemAmount(berryType2, amount3);
                    game.insertAction(nextAction8);
                    this.nameUpper = this.nameUpper.replace("_full", "_empty");
                    init();
                }
            } else if (this.nameUpper.equals("chest1")) {
                if (this.routeBelongsTo == null) {
                    this.routeBelongsTo = new Route("", 2);
                }
                game.playerCanMove = false;
                game.insertAction(new WaitFrames(game, 10, new CallMethod(this.overSprite, "setRegion", new Object[]{16, 0, 16, 32}, new PlayMusic("enter1", (Action) null))));
                game.insertAction(new WaitFrames(game, 16, new DrawPokemonMenu.Intro(new DrawPokemonMenu(game, true, this, null))));
            } else if (this.nameUpper.contains("campfire") && game.playerCanMove) {
                game.playerCanMove = false;
                game.player.isCrafting = true;
                game.insertAction(new DrawCraftsMenu.Intro(null, 9, new DrawCraftsMenu(game, new SetField(game, "playerCanMove", true, new SetField(game.player, "isCrafting", false, null)))));
            }
        } else if (game.type == Game.Type.CLIENT) {
            game.client.sendTCP(new Network.PickupItem(game.player.network.id, game.player.dirFacing));
        } else {
            game.playerCanMove = false;
            String number = "a";
            String plural = "";
            if (this.hasItemAmount > 1) {
                number = String.valueOf(this.hasItemAmount);
                plural = "S";
                if (this.hasItem.endsWith("s")) {
                    plural = "ES";
                }
            }
            game.insertAction(new DisplayText(game, "Found " + number + " " + this.hasItem.toUpperCase(Locale.ROOT) + plural + "!", "fanfare1.ogg", (Action) null, new WaitFrames(game, 6, new SetField(game, "playerCanMove", true, null))));
            pickUpItem(game.player);
        }
    }

    /* loaded from: pokewilds.jar:com/pkmngen/game/Tile$FlipDoorTile.class */
    public static class FlipDoorTile extends Action {
        ArrayList<Tile> flipDoors;

        @Override // com.corona.game.Action
        public void step(Game game) {
            Iterator<Tile> it = this.flipDoors.iterator();
            while (it.hasNext()) {
                it.next().flipDoorTile();
            }
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }

        public FlipDoorTile(ArrayList<Tile> flipDoors, Action nextAction) {
            super(new Object[0]);
            this.flipDoors = flipDoors;
            this.nextAction = nextAction;
        }
    }

    public void flipDoorTile() {
        String name;
        String[] tokens = this.name.split("__");
        if (tokens.length < 2) {
            System.out.println("somethings wrong.");
            return;
        }
        String name2 = tokens[0];
        if (tokens[1].equals("on")) {
            name = name2 + "__off";
            this.isSolid = false;
        } else {
            name = name2 + "__on";
            this.isSolid = true;
        }
        this.name = name;
        this.sprite = TextureCache.getTileSprite("buildings/" + name);
        this.sprite.setPosition(this.position.x, this.position.y);
    }

    public void onWalkOver() {
    }

    public boolean leavesFootprint() {
        return this.name.equals("desert4") || this.name.equals("snow2") || this.name.equals("snow5") || this.name.equals("snow6");
    }
}
